1.现有一个GridView
2.给此控件添加一个模板
3.在模板里放入一个DropDownList控件
4.在GridView外放一个按钮
5.要实现的内容:运行后GridView显示一列DropDownList控件,
6.我的问题是:单击GridView外的按钮,如何获取某一行的DropDownList的Text值
谢谢!

解决方案 »

  1.   


    DropDownList dropdownlist1 = (DropDownList)grdShow.Rows["行数"].Cells["列数"].FindContro("DropDownList1");
      

  2.   

    //获取第一行的DropDownList
    DropDownList dd=GridView1.Rows[0].FindControl("DropDownList1") as DropDownList;
      

  3.   

    string str=((DropDownList)grdShow.Rows["行数"].Cells["列数"].FindContro("DropDownList1")).SelectedValue;
      

  4.   

    foreach (GridViewRow gvr in GridView2.Rows)
        {
          DropDownList ch = (DropDownListch)gvr.FindControl("DropDownList1");
         
        }
      

  5.   

    DropDownList dropdownlist1 = (DropDownList)grdShow.Rows["行数"].Cells["列数"].FindContro("DropDownList1");
      

  6.   

    能说详细点吗?   你放了个摸般, 那不是有几行就有几个DropDownList, 这时候你选种一个DropDownList, 然后点按钮, 弹出TEXT .如果这样, 当你选种 DropDownList的时候, 就记录起来他是哪行. 设置个全局变量 接受
    然后DropDownList dropdownlist1 = (DropDownList)grdShow.Rows[全局变量].Cells["列数"].FindContro("DropDownList1");
      

  7.   

    参见
    http://dotnet.aspx.cc/file/Add-Delete-Update-Edit-Data-With-Paging-in-GridView.aspx
      

  8.   

    什么意思?弹出TEXT?当你选种 DropDownList的时候, 就记录起来他是哪行. 设置个全局变量?能讲的详细点吗?那全局变量从哪儿获取的?
      

  9.   


    关键是你的行号怎么确定的
    是点击行?还是点击那行的按钮?
    http://dotnet.aspx.cc/file/Add-Delete-Update-Edit-Data-With-Paging-in-GridView.aspx这个例子很能说明问题了
      

  10.   

    在选择了DropDownList的Text值的时候如何获取当前行的索引?
      

  11.   

    protected void Button1_Click(object sender, EventArgs e)  
      {  
    GridViewRow gvr = (sender as LinkButton).NamingContainer as GridViewRow;   
    DropDownList txt=gvr.FindControl("ddl") as DropDownList ;  
    }