简体   繁体   English

从 Gridview 级联两个下拉列表的 select 值

[英]select values of Cascading two dropdownlists from Gridview

I have two dropdownlist and one Gridview, I want to select two Dropdownlists by select the row from Gridview. I have two dropdownlist and one Gridview, I want to select two Dropdownlists by select the row from Gridview. the problem is the first Dropdownlist is working, but the second is not.问题是第一个 Dropdownlist 正在工作,但第二个没有。 在此处输入图像描述

the dropdownlist that shows (mobile) works and selected according to gridview row selected.显示(移动)工作的下拉列表根据选择的 gridview 行进行选择。 however, dropdownlist (galaxy) does not select the one we select from Gridview.但是,下拉列表(星系)不 select 是我们 select 来自 Gridview 的一个。 here is the code which we wrote on page load,the first gridview is working but not the second.这是我们在页面加载时编写的代码,第一个 gridview 正在工作,但第二个没有。

在此处输入图像描述

  please try this code
   protected void Grid_SelectedIndexChanged(object sender, EventArgs e)
    {
       GridViewRow row = gvSummary.SelectedRow;
       string name= row.Attributes["Name"].ToString());
       string brandName = row.Attributes["brand_name"].ToString());
        DropDownList1.SelectedValue = name
        DropDownList2.SelectedValue = brandName; 

     } 

在此处输入图像描述

this is the error, which the [name] is not recognized这是错误,无法识别 [name]

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

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