gridview的编辑模式(EditItemTemplate)里,某列嵌套一个dropdownlist
因为修改是限制,所以我就只能用dropdownlist,ddl里的值是从另外一个表里抓的。具体来说 当用户看的时候,这列的值是:北京 但是要修改的话,我就要从CITY表里获得数据 比如限制修改成 上海或重庆或北京(默认还是北京),不能成为其他的字段 我现在都不知道该在哪个事件里写了,请高手赐教
因为修改是限制,所以我就只能用dropdownlist,ddl里的值是从另外一个表里抓的。具体来说 当用户看的时候,这列的值是:北京 但是要修改的话,我就要从CITY表里获得数据 比如限制修改成 上海或重庆或北京(默认还是北京),不能成为其他的字段 我现在都不知道该在哪个事件里写了,请高手赐教
解决方案 »
- 如何按这个窗体高度变化,改变TREEVIEW的高度?
- 求助:Accept-Encoding 被isp篡改为 BCcept-Encoding GZIP无法使用
- 音频文件为啥播放不了?
- vs.net 使用问题
- 已经一个星期了,问题没解决,跪求各位给个答案
- 再发,怎么横排显示
- 请各位兄弟给点建议:RadioButtonList控件与DataGrid显示不同表
- 购买系统分析员的复习资料...
- 把datagrid中的5萬多條記錄導出到一個excel表時出錯.請問要怎樣解決呀.
- 怎样得到calendar控件所选择的日期
- datagrid中的两个列(车牌和车号)想合成一个列(车牌号)怎么做?
- 登陆后没刷新就无法正常显示
if (gvr.RowType == DataControlRowType.DataRow)
{
}
#endregion
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
DropDownList DDL = (DropDownList)e.Row.FindControl("DropDownList1");
DataRowView DRV = (DataRowView)e.Row.DataItem;
int id = Convert.ToInt32(DRV["stid"]);
DDL.SelectedIndex = id;
DDL.DataSource = ConStr.Dt("select * from bigtitle");
DDL.DataBind();
DDL.DataTextField = "btid";
DDL.DataValueField = "btname";
}
}
我这么写,点编辑的时候显示找不到dropdownlist1 谁写过,把具体代码给我把
后台代码:
public SqlDataReader ddlBind()
{
SqlDataReader dr = Pro.selectAllBrand();//从数据表取出数据
return dr;
}
前台页面绑定(DataSource='<%#ddlBind()%>'):
<asp:TemplateField HeaderText="品牌">
<EditItemTemplate>
<asp:DropDownList ID="DropDownList4" runat="server" DataSource='<%#ddlBind()%>' DataTextField='brand' DataValueField='id' Width="70px">
<asp:ListItem Value="00">-请选择-</asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>