gridview绑定dropdownlist
为什么我的gridview绑定dropdownlist,dropdownlist里不显示数据呢?<asp:TemplateFieldHeaderText="付款形式"So...
为什么我的gridview绑定dropdownlist,dropdownlist里不显示数据呢?
<asp:TemplateField HeaderText="付款形式" SortExpression="FKXS" ItemStyle-HorizontalAlign="Center">
<ItemTemplate>
<asp:DropDownList ID="DDLFKXS" runat="server" AutoPostBack="True" DataSourceID='<%# Eval("FKXS") %>' DataTextField='<%# Eval("FKXS") %>' DataValueField='<%# Eval("FKXS") %>'>
</asp:DropDownList> </ItemTemplate>
</asp:TemplateField>
后台:
protected void gvList_RowDataBound(object sender, GridViewRowEventArgs e)
{
DropDownList ddlFKXS = new DropDownList();
if (((DropDownList)e.Row.FindControl("FKXS")) != null)
{
ddlFKXS =(DropDownList)e.Row.FindControl("FKXS");
ddlFKXS.Items.Clear();
ddlFKXS.Items.Add(new ListItem("现金", "现金"));
ddlFKXS.Items.Add(new ListItem("转账支票", "转账支票"));
ddlFKXS.Items.Add(new ListItem("电汇", "电汇"));
ddlFKXS.Items.Add(new ListItem("承兑汇票", "承兑汇票"));
//DropDownList初始被选择的项
ddlFKXS.SelectedValue = ((HiddenField)e.Row.FindControl("FKXS")).Value;
}
else
{
ddlFKXS.Items.Clear();
ddlFKXS.Items.Add(new ListItem("现金", "现金"));
ddlFKXS.Items.Add(new ListItem("转账支票", "转账支票"));
ddlFKXS.Items.Add(new ListItem("电汇", "电汇"));
ddlFKXS.Items.Add(new ListItem("承兑汇票", "承兑汇票"));
}
}
大家帮帮忙,在线等 展开
<asp:TemplateField HeaderText="付款形式" SortExpression="FKXS" ItemStyle-HorizontalAlign="Center">
<ItemTemplate>
<asp:DropDownList ID="DDLFKXS" runat="server" AutoPostBack="True" DataSourceID='<%# Eval("FKXS") %>' DataTextField='<%# Eval("FKXS") %>' DataValueField='<%# Eval("FKXS") %>'>
</asp:DropDownList> </ItemTemplate>
</asp:TemplateField>
后台:
protected void gvList_RowDataBound(object sender, GridViewRowEventArgs e)
{
DropDownList ddlFKXS = new DropDownList();
if (((DropDownList)e.Row.FindControl("FKXS")) != null)
{
ddlFKXS =(DropDownList)e.Row.FindControl("FKXS");
ddlFKXS.Items.Clear();
ddlFKXS.Items.Add(new ListItem("现金", "现金"));
ddlFKXS.Items.Add(new ListItem("转账支票", "转账支票"));
ddlFKXS.Items.Add(new ListItem("电汇", "电汇"));
ddlFKXS.Items.Add(new ListItem("承兑汇票", "承兑汇票"));
//DropDownList初始被选择的项
ddlFKXS.SelectedValue = ((HiddenField)e.Row.FindControl("FKXS")).Value;
}
else
{
ddlFKXS.Items.Clear();
ddlFKXS.Items.Add(new ListItem("现金", "现金"));
ddlFKXS.Items.Add(new ListItem("转账支票", "转账支票"));
ddlFKXS.Items.Add(new ListItem("电汇", "电汇"));
ddlFKXS.Items.Add(new ListItem("承兑汇票", "承兑汇票"));
}
}
大家帮帮忙,在线等 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询