FineUI 官方论坛
标题:
grid里两个dropdownlist的模板列实现联动
[打印本页]
作者:
会编程的唐伯虎
时间:
2016-7-28 00:01
标题:
grid里两个dropdownlist的模板列实现联动
grid里有2个模板列,均为gropdownList,要实现前面一个dropdownlist列的选项值改变后,重新绑定后边一个dropdownList的绑定值
前台页面显示 和 代码如下:
[attach]9052[/attach]
<Columns>
<f:RowNumberField />
<f:BoundField DataField="SEQUENCE" SortField="SEQUENCE" Width="100px" HeaderText="顺序号" />
<f:BoundField DataField="OPER_NAME" SortField="OPER_NAME" Width="100px" HeaderText="工序名称" />
<f:BoundField DataField="TotalQty" SortField="TotalQty" Width="100px" HeaderText="生产总数" />
<f:BoundField DataField="AssignedQty" SortField="AssignedQty" Width="100px" HeaderText="已派工数量" />
<f:BoundField DataField="LeftQty" SortField="LeftQty" Width="100px" HeaderText="剩余派工数量" />
<f:TemplateField HeaderText="分派数量" Width="100px">
<ItemTemplate>
<asp:TextBox ID="txtAssignQty" runat="server" Width="80px" TabIndex='<%# Container.DataItemIndex + 10 %>'
Text='<%# Eval("AssignQty") %>'></asp:TextBox>
</ItemTemplate>
</f:TemplateField>
<f:TemplateField Width="100px" HeaderText="分派人员">
<ItemTemplate>
<asp:DropDownList runat="server" ID="ddlUser" OnSelectedIndexChanged="ddlUser_SelectedIndexChanged">
</asp:DropDownList>
</ItemTemplate>
</f:TemplateField>
<f:TemplateField Width="100px" HeaderText="分派设备">
<ItemTemplate>
<asp:DropDownList runat="server" ID="ddlUnit" >
</asp:DropDownList>
</ItemTemplate>
</f:TemplateField>
<f:LinkButtonField HeaderText=" " Width="80px" CommandName="ADD" Icon="Add" ColumnID="Grid1_ctl15" />
</Columns>
复制代码
后台代码如下:
[attach]9053[/attach]
protected void ddlUser_SelectedIndexChanged(object sender, EventArgs e)
{
System.Web.UI.WebControls.DropDownList selectUserDDL = (System.Web.UI.WebControls.DropDownList)sender;
int Index = ((GridViewRow)(selectUserDDL.NamingContainer)).RowIndex;
System.Web.UI.WebControls.DropDownList ddlUnit = (System.Web.UI.WebControls.DropDownList)Grid1.Rows[Index].FindControl("ddlUnit");
ddlUnit.Items.Clear();
string EmployeeNO = selectUserDDL.SelectedValue;
DataSet unitDS = new BLL.TBLJN_WORKUNIT_USER().GetUnitInfoByUser(EmployeeNO);
if (unitDS != null && unitDS.Tables.Count > 0)
{
if (unitDS.Tables[0].Rows.Count > 0)
{
foreach (DataRow drUnit in unitDS.Tables[0].Rows)
{
System.Web.UI.WebControls.ListItem itemUnit = new System.Web.UI.WebControls.ListItem();
itemUnit.Value = drUnit["ID"].ToString();
itemUnit.Text = drUnit["WORK_UNIT_NO"].ToString() + "(" + drUnit["WORK_UNIT_NAME"].ToString() + ")";
ddlUnit.Items.Add(itemUnit);
}
}
else
{
Model.TBLJN_WORK_UNIT unitModel = new BLL.TBLJN_WORK_UNIT().GetModelByWorkUnitNO("other");
if (unitModel != null)
{
System.Web.UI.WebControls.ListItem itemUnit = new System.Web.UI.WebControls.ListItem();
itemUnit.Value = unitModel.ID.ToString();
itemUnit.Text = unitModel.WORK_UNIT_NAME;
ddlUnit.Items.Add(itemUnit);
}
}
ddlUnit.SelectedIndex = 0;
}
}
复制代码
可是发现当第一个 dropdownlist值改变时,并未进入到后台的
OnSelectedIndexChanged事件中去,请问这个要怎么实现呢??????
作者:
zy32002
时间:
2016-7-28 08:41
实现不了,只能用js
作者:
yilei163
时间:
2016-7-28 14:25
一般使用ajax来实现表格行内联动
欢迎光临 FineUI 官方论坛 (https://fineui.com/BBS/)
Powered by Discuz! X3.4