问了很久都没人能明确回答的问题,谢谢大家
发表于:2008-08-27 15:08:50 楼主
public class ColumnTemplate : ITemplate
{
public void InstantiateIn(Control container)
{
DropDownList dbl=new DropDownList();
dbl.ID="dblpro_storage";
dbl.DataBinding+=new System.EventHandler(this.BindtbColumn);
container.Controls.Add(dbl);
}
public void BindtbColumn(object sender, EventArgs e)
{
DropDownList dbl= (DropDownList) sender;
DataGridItem container = (DataGridItem) dbl.NamingContainer;
string pp=((DataRowView)container.DataItem)["id"].ToString();
dbl.DataTextField ="storage_name";
dbl.DataValueField ="storage_ID";
dbl.DataSource =getstoragelist();
dbl.Items.Insert(0,new ListItem("请选择仓库","0")); //这儿不起作用
dbl.SelectedValue =((DataRowView)container.DataItem)["pro_storage"].ToString();//这儿会出错
}
}
------解决方案--------------------断点调试一下,貌似没什么可疑的地方
------解决方案--------------------顶
------解决方案--------------------dbl.DataSource =getstoragelist();
dbl.DataBinding();
dbl.Items.Insert(0,new ListItem("请选择仓库","0"));
------解决方案--------------------究竟出什么错啊~~~~~~~~提示什么~~~~~~
------解决方案--------------------C# code
protected void DropDownList1_DataBound(object sender, EventArgs e)
{
this.DropDownList1.Items.Add(new ListItem("请选择", "0"));
this.DropDownList1.SelectedIndex = DropDownList1.Items.Count - 1;
}
------解决方案--------------------
代码应该没问题
------解决方案--------------------
没看明白什么问题,相关的代码都要贴出来啊。