簡體   English   中英

從網格視圖的下拉列表中獲取命令ID

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

我從后面的代碼中將一個下拉列表插入到我的網格視圖中,就像在這里完成的那樣。 將gridview字段轉換為Dropdownlist ,當更改其選定索引時,我需要在包含此dropdownlist的行中執行命令。 請能幫我一個忙嗎

如果需要獲取動態生成的DropDownListGridViewRow ,請使用以下方法。

將相同的SelectedIndexChanged -event處理程序添加到下拉列表中。 處理它,將senderDropDownList ,將其NamingContainerGridViewRow 現在您已經准備就緒。

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