我想知道如果我们触发网格的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.
}
答案 0 :(得分:1)
假设您已经在页面加载时填充了DDL,并且row.Cell[0]
值在DDL中。这是您从row.Cells[0]
DDL.SelectedIndex=DDL.Items.IndexOf(DDL.Items.FindByText(row.Cells[0].Text));