【问题标题】:Selected item of dropdownlist if we trigger a rowcommand event?如果我们触发 rowcommand 事件,下拉列表的选定项?
【发布时间】:2014-03-25 05:46:07
【问题描述】:

我想知道如果我们触发网格的 rowcommand 事件,将如何选择下拉列表的选定项。我对字符串做得很好,我不知道下拉列表。我的代码在这里,

if (e.CommandName == "Select")
{
    GridViewRow row =(GridViewRow)(((LinkButton)e.CommandSource).NamingContainer);                
    txtRoomCode.Text = row.Cells[1].Text.Replace("@nbsp;", "");
    txtRoomName.Text = row.Cells[2].Text.Replace("@nbsp;", "");
    // here is my dropdownlist, I want the value of row.Cells[0] to be in dropdownlist.
}

【问题讨论】:

    标签: c# asp.net gridview


    【解决方案1】:

    假设您已经在页面加载时填充了 DDL,并且 row.Cell[0] 值在 DDL 中。这就是您从row.Cells[0] 中选择特定 DDL 值的方法

    DDL.SelectedIndex=DDL.Items.IndexOf(DDL.Items.FindByText(row.Cells[0].Text));
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-07-19
      • 1970-01-01
      • 1970-01-01
      • 2012-01-19
      • 1970-01-01
      相关资源
      最近更新 更多