在gridview下拉列表中选择更改事件 [英] in gridview dropdown selected change event
本文介绍了在gridview下拉列表中选择更改事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
尊敬的先生,
我有一个网格视图,其中一列包括带有Dropdown
的itemtemplate
我在列中绑定了第一个下拉列表
Dear sir,
i have a grid view in which one column consist of itemtemplate with Dropdown
i binded first dropdown in a column
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (e.Row.RowIndex == 0)
{
DataTable dt = new DataTable();
string str1 = e.Row.Cells[4].Text.ToString();
string str2 = "0";
dt = BLAutoComplete.GetFirstDdl(str1, str2);
DropDownList DDL = (DropDownList)e.Row.FindControl("ddl1");
DDL.DataSource = dt;
DDL.DataTextField = "CURRENT_NAME";
DDL.DataValueField = "CURRENT_ID";
DDL.DataBind();
DDL.Items.Insert(0, "--Select--");
}
}
}
我需要第一行下拉selectedindex更改我需要绑定同一列第二行下拉
i need first row dropdown selectedindex change i need to bind same column second row dropdown
推荐答案
如果删除以下条件怎么办?
What if you remove the following condition?
if (e.Row.RowIndex == 0)
为在行数据绑定事件和dropdownselectionchanged事件中更改的下拉选择创建一个偶数处理程序
Create an even handler for dropdown selection changed in row databound event and in dropdownselectionchanged event
foreach (GridViewRow gr in GridView1.Rows)
{
DropDownList DDL = (DropDownList)gr.FindControl("DropDownList2");
if (gr.RowIndex == 1)
{
// code to populate dropdownlist
}
}
这篇关于在gridview下拉列表中选择更改事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文