请教一个DataGrid+DropDownList的问题 在DataGrid中使用模板列,在EditTemplate中使用DropDownList,可供用户选择一些选项,但是我想在开始编辑此列时,DropDownList选中和数据库中保存的值相对应的item,该如何做? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 可以在绑定时调用一个函数,在函数里面将ddl和SelectItemIndex设置一下<asp:TemplateColumn HeaderText="Read"><ItemTemplate><asp:DropDownList ID="ddl" SelectedIndex ='<%# GetIndex(DataBinder.Eval(Container, "DataItem.colname")) %>' Runat ="server" ></asp:DropDownList></asp:CheckBox></ItemTemplate></asp:TemplateColumn> 看这个就解决了:http://www.ccw.com.cn/applic/prog/htm2003/20030828_13IYP.asp这个也可以,不过是英语的:http://www.csharphelp.com/archives/archive212.html http://www.cnblogs.com/lovecherry/archive/2005/03/25/125525.html <ItemTemplate>//...</ItemTemplate><EditTemplate><asp:DropDownList ID="ddl" Runat ="server" ></asp:DropDownList></EditTemplate>在编辑事件里DropDownList ddl = e.Item.Cells[该模板列的Index].FindControl("ddl");ddl.DataSource = 要绑定的数据源;ddl.DataTextField="显示文本的字段";//如"EmployeeName"ddl.DataValueField="文本对应的值的字段";//如"EmployeeID"ddl.DataBind();ddl.SelectedValue = ((DataRowView)e.Item.DataItem).Row["文本对应的值的字段,如EmployeeID"].ToString(); 外包公司一般用什么框架 急急急:ASP.NET 使用NetworkConnection连接网络映射文件夹时,连接status返回71,是什么问题? 命名空间的问题!! 大家来帮帮忙 我有好心人帮帮我吗?都郁闷一天了。 怎样取得存储过程的返回值呢? 很有难度的字符匹配谁能解决 我刚接手一台电脑,.net工具箱中没有web控件选项卡,但是在html窗体中输入代码,设计窗体中可以显示出该控件。 页面刷新问题! 怎么从数据库中的image字段中读取字节,生成相应的文件? 如何获取一个帧里面的元素的绝对高度 大家看看两者有什么区别? 请问RadioButtonlist右边如何显示图片?
<asp:TemplateColumn HeaderText="Read">
<ItemTemplate>
<asp:DropDownList ID="ddl" SelectedIndex ='<%# GetIndex(DataBinder.Eval(Container, "DataItem.colname")) %>' Runat ="server" ></asp:DropDownList>
</asp:CheckBox>
</ItemTemplate>
</asp:TemplateColumn>
http://www.ccw.com.cn/applic/prog/htm2003/20030828_13IYP.asp这个也可以,不过是英语的:
http://www.csharphelp.com/archives/archive212.html
//...
</ItemTemplate>
<EditTemplate>
<asp:DropDownList ID="ddl" Runat ="server" ></asp:DropDownList>
</EditTemplate>在编辑事件里
DropDownList ddl = e.Item.Cells[该模板列的Index].FindControl("ddl");
ddl.DataSource = 要绑定的数据源;
ddl.DataTextField="显示文本的字段";//如"EmployeeName"
ddl.DataValueField="文本对应的值的字段";//如"EmployeeID"
ddl.DataBind();ddl.SelectedValue = ((DataRowView)e.Item.DataItem).Row["文本对应的值的字段,如EmployeeID"].ToString();