本文介绍了如何将interger值传递给列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨伙计,
我对列表有一些小问题。
Hi Folks,
I have small question regarding lists.
private void ComboBox_SelectedValueChanged(object sender, EventArgs e)
{
if (dataSourceNameComboBox.SelectedItem != null)
{
int dataval = Convert.ToInt32(datatypeComboBox.SelectedIndex);
Model.ContProduct.Id= dataval ;
Model.Contlist.ToList<>();
}
}
----- Here I want to pass 'dataval' value to the Model.Contlist.ToList<>(); list to filter the data-----
BLL:
public List<ContlistViewModel> Contlist{ get; set; }
DAL:
public class ContlistViewModel
{
public int Id { get; set; }
public string Name{ get; set; }
public string Description{ get; set; }
}
推荐答案
private void ComboBox_SelectedValueChanged(object sender, EventArgs e)
{
if (dataSourceNameComboBox.SelectedItem != null)
{
int dataval = Convert.ToInt32(datatypeComboBox.SelectedIndex);
Model.ContProduct.Id= dataval ;
ContListViewModel cvm = Model.Contlist[dataval];
...
}
}
但说实话,我可能会直接使用ContlistViewModel项加载Comboxbox,而是使用SelectedItem属性,覆盖必要时在类中使用ToString。
But to be honest, I'd probably load the Comboxbox with the ContlistViewModel items directly, and use the SelectedItem property instead, overriding ToString in the class as necessary.
这篇关于如何将interger值传递给列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!