asp 里 gridview/TemplateField/EditItemTemplate 里面的dropdownlist控件如何iterm。add
具体代码如下:前台:<asp:TemplateFieldHeaderText="竞得人"><ItemTemplate><%#Eval("EnterpriseName")%...
具体代码如下:
前台:
<asp:TemplateField HeaderText="竞得人">
<ItemTemplate>
<%# Eval("EnterpriseName")%>
</ItemTemplate>
<EditItemTemplate>
<asp:DropDownList ID="EnterpriseName" runat="server" Text='<%# Bind("EnterpriseName") %>' cName='<%# Eval("ID") %>'>
</asp:DropDownList>
</EditItemTemplate>
<ItemStyle HorizontalAlign="Left" />
</asp:TemplateField>
后台:
protected void GridViewer1_RowEditing(object sender, GridViewEditEventArgs e)
{
..............
string sql = "select enterprisename from projectbid where projectid='" + Request.QueryString["ProjectID"].ToString() + "'";
DataTable dt = SQL.GetDataTable("", SQL.DBConnStr, sql);
DropDownList ddlenter = (DropDownList)GridViewer1.Rows[e.NewEditIndex].Cells[3].FindControl("EnterpriseName");
foreach (DataRow dr in dt.Rows)
{
ListItem li = new ListItem(dr["enterprisename"].ToString(), dr["enterprisename"].ToString());
ddlenter.Items.Add(li);
}
...................
}
其中ddlenter的值为null,也就是说没从gridview中取到控件,请问这是为什么 展开
前台:
<asp:TemplateField HeaderText="竞得人">
<ItemTemplate>
<%# Eval("EnterpriseName")%>
</ItemTemplate>
<EditItemTemplate>
<asp:DropDownList ID="EnterpriseName" runat="server" Text='<%# Bind("EnterpriseName") %>' cName='<%# Eval("ID") %>'>
</asp:DropDownList>
</EditItemTemplate>
<ItemStyle HorizontalAlign="Left" />
</asp:TemplateField>
后台:
protected void GridViewer1_RowEditing(object sender, GridViewEditEventArgs e)
{
..............
string sql = "select enterprisename from projectbid where projectid='" + Request.QueryString["ProjectID"].ToString() + "'";
DataTable dt = SQL.GetDataTable("", SQL.DBConnStr, sql);
DropDownList ddlenter = (DropDownList)GridViewer1.Rows[e.NewEditIndex].Cells[3].FindControl("EnterpriseName");
foreach (DataRow dr in dt.Rows)
{
ListItem li = new ListItem(dr["enterprisename"].ToString(), dr["enterprisename"].ToString());
ddlenter.Items.Add(li);
}
...................
}
其中ddlenter的值为null,也就是说没从gridview中取到控件,请问这是为什么 展开
1个回答
威孚半导体技术
2024-08-19 广告
2024-08-19 广告
威孚(苏州)半导体技术有限公司是一家专注生产、研发、销售晶圆传输设备整机模块(EFEM/SORTER)及核心零部件的高科技半导体公司。公司核心团队均拥有多年半导体行业从业经验,其中技术团队成员博士、硕士学历占比80%以上,依托丰富的软件底层...
点击进入详情页
本回答由威孚半导体技术提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询