GridView嵌套Dropdownlist 怎么弄
GridView嵌套Dropdownlist怎么弄gridView里嵌套DropDownList要联动的最好有代码发我邮箱我一定给你们100分谢谢Email:zhibg@...
GridView嵌套Dropdownlist 怎么弄
gridView里嵌套DropDownList 要联动的
最好有代码 发我邮箱 我一定给你们100分
谢谢
Email:zhibg@sina.com
大哥 我再不知道加模版?
我要的是GridView嵌套Dropdownlist并且联动 懂吗?? 展开
gridView里嵌套DropDownList 要联动的
最好有代码 发我邮箱 我一定给你们100分
谢谢
Email:zhibg@sina.com
大哥 我再不知道加模版?
我要的是GridView嵌套Dropdownlist并且联动 懂吗?? 展开
2个回答
2009-08-27
展开全部
你的意思是GridView绑定时给Dropdownlist 绑定一个选项,然后Dropdownlist更改后把结果保存回数据库?
前台
<asp:TemplateField HeaderText="订单操作">
<HeaderStyle Font-Bold="false" Width="80px" />
<ItemStyle Width="80px" />
<ItemTemplate>
<asp:DropDownList ID="ddlState" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlState_SelectedIndexChanged">
<asp:ListItem Value="0">未审核</asp:ListItem>
<asp:ListItem Value="1">未服务</asp:ListItem>
<asp:ListItem Value="2">审核未通过</asp:ListItem>
<asp:ListItem Value="3">原文未找到</asp:ListItem>
<asp:ListItem Value="4">已服务</asp:ListItem>
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
后台
/// <summary>
/// 状态下拉列表框绑定
/// </summary>
protected void gvUserOrderdDetail_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
DataRowView rowItem = (DataRowView)e.Row.DataItem;
DropDownList ddlState = (DropDownList)e.Row.FindControl("ddlState");
if (rowItem["ServiceState"] != DBNull.Value)
{
if ((rowItem["ServiceState"].ToString()).Equals("4"))
{
ddlState.Items.FindByValue(rowItem["ServiceState"].ToString()).Selected = true;
ddlState.Enabled = false;
}
else
{
ddlState.Items.FindByValue(rowItem["ServiceState"].ToString()).Selected = true;
}
}
//DD1.SelectedValue = DataBinder.Eval(e.Row.DataItem, "ServiceState").ToString();
////DD1.Items.FindByText(rowItem["ServiceState "].ToString()).Selected = true;
}
}
前台
<asp:TemplateField HeaderText="订单操作">
<HeaderStyle Font-Bold="false" Width="80px" />
<ItemStyle Width="80px" />
<ItemTemplate>
<asp:DropDownList ID="ddlState" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlState_SelectedIndexChanged">
<asp:ListItem Value="0">未审核</asp:ListItem>
<asp:ListItem Value="1">未服务</asp:ListItem>
<asp:ListItem Value="2">审核未通过</asp:ListItem>
<asp:ListItem Value="3">原文未找到</asp:ListItem>
<asp:ListItem Value="4">已服务</asp:ListItem>
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
后台
/// <summary>
/// 状态下拉列表框绑定
/// </summary>
protected void gvUserOrderdDetail_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
DataRowView rowItem = (DataRowView)e.Row.DataItem;
DropDownList ddlState = (DropDownList)e.Row.FindControl("ddlState");
if (rowItem["ServiceState"] != DBNull.Value)
{
if ((rowItem["ServiceState"].ToString()).Equals("4"))
{
ddlState.Items.FindByValue(rowItem["ServiceState"].ToString()).Selected = true;
ddlState.Enabled = false;
}
else
{
ddlState.Items.FindByValue(rowItem["ServiceState"].ToString()).Selected = true;
}
}
//DD1.SelectedValue = DataBinder.Eval(e.Row.DataItem, "ServiceState").ToString();
////DD1.Items.FindByText(rowItem["ServiceState "].ToString()).Selected = true;
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询