dropdownlist 问题
1. 在自定义中
DDL.ID= "droplist "+ i.ToString();
DDL.Items.Add( "文本框 ");
DDL.Items.Add( "下拉框 ");
DDL.Items.Add( "多选框 ");
这样只能取其text的值,如何在加入value的值如1,2,3 以便插入数据库
2.如何将 Parent_ID=0的值在dropdownlist中用#008888表示出来:
我写的这个为何用不了
foreach(DataRow dr in ds.Tables[0].Select( "Parent_ID=0 "))
{
ddl.Items[0].Attributes.Add( "style ", "BACKGROUND-COLOR: #008888 ");
AddItems(ds,dr,String.Empty);
}
取 Parent_ID=0的
------解决方案--------------------DDL.Items.FindByText( "文本框 ").Value = "1 ";
DDL.Items.FindByText( "下拉框 ").Value = "2 ";
DDL.Items.FindByText( "多选框 ").Value = "3 ";
------解决方案--------------------DDL.Items.Add(new ListItem( "text ", "value "))
------解决方案--------------------1. 在自定义中
DDL.ID= "droplist "+ i.ToString();
DDL.Items.Add(new ListItem( "文本框 ", "1 "));
DDL.Items.Add(new ListItem( "下拉框 ", "2 "));
DDL.Items.Add(new ListItem( "多选框 ", "3 "));
------解决方案--------------------int i = 0;
foreach(DataRow dr in ds.Tables[0].Select( "Parent_ID=0 "))
{
if(ddl.Items[i].Value == dr[ "id "].ToString())
{
ddl.Items[i].Attributes.Add( "style ", "BACKGROUND-COLOR: #008888 ");
}
i ++;
AddItems(ds,dr,String.Empty);
}