DropDownList绑定 [英] DropDownList Bind

查看:56
本文介绍了DropDownList绑定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好.

我有问题.我有一个网格视图,其中放置了下拉列表.现在我想在其他索引的选定索引更改处将项目添加到一个drpdwnlist中.我的问题是我无法获得该特定的下拉列表
在第一个下拉列表的选定索引更改处..任何想法都可以帮助我感到非常困惑.我已将其绑定.但是还有另一个问题,请看一下选定索引更改中的代码.
受保护的void DropDownList2_SelectedIndexChanged(对象发送者,EventArgs e)
{
DropDownList ddl =发送者为DropDownList;
字符串BuildingName = ddl.SelectedItem.Text;
Int32 buildid = objbuilding.slect_bid_for_floor(BuildingName);
数据集dsss = OBJFLOOR.FloorId_Acc_Building(buildid);
//int index = Convert.ToInt32(GridView1.SelectedRow.RowIndex);
//DropDownList ddlg =(DropDownList)(GridView1.SelectedRow.FindControl("DrpFloor"));
//控制gridrow = GridView1.Rows;
GridViewRow rr = GridView1.SelectedRow;
foreach(在GridView1.Rows中控制网格行)
{
DropDownList ddlg =(DropDownList)gridrow.FindControl("DrpFloor");

ddlg.DataSource = dsss.Tables [0];
ddlg.DataTextField ="Floor_Name";
ddlg.DataValueField ="Fid";
ddlg.DataBind();
ddlg.Items.Insert(0,new ListItem("Select","-1"));
}
//DropDownList ddlg =(DropDownList)(GridView1.FindControl("DrpFloor"));

}

现在我的DropDown已绑定,但这绑定了所有DropDowm.我在网格视图中创建了Dyanamic行,我想单独绑定每个DropDown请让我知道...有这么多Gr8编程器没有人知道Sol ....

hi everyone.

I Have problem.i have a grid view in which i have put dropdown list.now i want to add the items to one of the drpdwnlist at the selected index change of other one.my problem is that i m nt getting that particular dropdownlist
at the selected index change of first dropdownlist ..can any have idea plz help i m very confused.I have Binded It .But There Is Another Problem Take a Look At The Code in Selected index Change.
protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e)
{
DropDownList ddl = sender as DropDownList;
string BuildingName = ddl.SelectedItem.Text;
Int32 buildid = objbuilding.slect_bid_for_floor(BuildingName);
DataSet dsss = OBJFLOOR.FloorId_Acc_Building(buildid);
// int index = Convert.ToInt32(GridView1.SelectedRow.RowIndex);
//DropDownList ddlg = (DropDownList)(GridView1.SelectedRow.FindControl("DrpFloor"));
// Control gridrow = GridView1.Rows;
GridViewRow rr = GridView1.SelectedRow;
foreach (Control gridrow in GridView1.Rows)
{
DropDownList ddlg = (DropDownList)gridrow.FindControl("DrpFloor");

ddlg.DataSource = dsss.Tables[0];
ddlg.DataTextField = "Floor_Name";
ddlg.DataValueField = "Fid";
ddlg.DataBind();
ddlg.Items.Insert(0, new ListItem("Select", "-1"));
}
// DropDownList ddlg = (DropDownList)(GridView1.FindControl("DrpFloor"));

}

Now My DropDown Is Binded But This Is Binding All The DropDowm.I Have Dyanamic Row Created In Grid View And I Want to Bind Each DropDown INdivisusally Please Let Me Know...There Are So Many Gr8 Programmer Doesn''t Any one know Sol....

推荐答案

只需让父代获取导致事件的行,然后找到下拉列表

Just get parent to get the row which caused the event and then find drop down

GridViewRow gvrow = (GridViewRow)((DropDownList)(sender)).NamingContainer;


这篇关于DropDownList绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆