WebCombo取组合框当前显示的文本

Code
<!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>-->1取组合框当前显示的文本,3种写法
2combNdGys.SelectedCell.ToString();当为编辑状态时,如果不是选,而是输入时,则出错,而comboPJNo.DisplayValue.ToString();则不出错
3ComboHtType.SelectedCell.Text;
4comboPJNo.DisplayValue.ToString();
5this.ComboHtType.SelectedRow.Cells[0].ToString()//所选行的第一列文本
6注:如果WebCombo不输入或留空时则出错
7
8解决方法:动态的编写语句(否则其会清空数据源,造成WebCombo不输入或留空时出错)
9protectedvoidPage_Load(objectsender,EventArgse)//动态的编写语句
10{
11if(!IsPostBack)
12{
13this.WebCombo2.DataSource=BuildStateList();
14this.WebCombo2.DataBind();
15this.WebCombo1.Columns.Clear();
16
17this.WebCombo1.DataSource=pzcDbHelperSQL.pzcGetDataTable("select*fromT_Custom");//动态装入
18this.WebCombo1.DataBind();
19this.WebCombo1.Columns[0].Header.Caption="pzc";
20}

21}

22protectedvoidButton2_Click(objectsender,EventArgse)
23{
24if(this.WebCombo1.DisplayValue==null)
25{
26Response.Write("null");
27}

28else{Response.Write(this.WebCombo1.DisplayValue.ToString());}
29
30}

31

你可能感兴趣的:(combo)