简体   繁体   English

从网格视图的下拉列表中获取命令ID

[英]getting command id from drop down list in a grid view

i inserted a drop down list into my grid view from the code behind like it is done here Convert gridview field into Dropdownlist i need to make command in the row that contains this dropdownlist when its selected index is changed. 我从后面的代码中将一个下拉列表插入到我的网格视图中,就像在这里完成的那样。 将gridview字段转换为Dropdownlist ,当更改其选定索引时,我需要在包含此dropdownlist的行中执行命令。 please can some one hepl me thanks 请能帮我一个忙吗

If you need to get the GridViewRow of a DropDownList which was generated dynamically use following approach. 如果需要获取动态生成的DropDownListGridViewRow ,请使用以下方法。

Add the same SelectedIndexChanged -event handler to the dropdowns. 将相同的SelectedIndexChanged -event处理程序添加到下拉列表中。 Handle it, cast sender to DropDownList , cast it's NamingContainer to GridViewRow . 处理它,将senderDropDownList ,将其NamingContainerGridViewRow Now you are all set. 现在您已经准备就绪。

protected void DropDown_SelectedIndexChanged(object sender, EventArgs e)
{
    DropDownList ddl = (DropDownList) sender;
    GridViewRow row =  (GridViewRow) ddl.NamingContainer;
    // now you get the reference to the other controls via row.FindControl
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM