详细的说一下我的问题 
我用的是一个gridview 他有多个列 
我把列做成了模板,在里面t拖入了一个DropDownList1 
但是在作数据绑定的时候每一个DropDownList1 就要写一次 
SQL语句,但是我的SQL语句大部分一样,只是查询条件不同 
传入的参数就是DropDownList1 所在的列的表头。 
我希望能够有一个通用的方法修改SQL语句。

解决方案 »

  1.   

    gridview 数据绑定protected void gridview_RowDataBound(object sender, GridViewRowEventArgs e)
        {     DropDownList DDL = (DropDownList)gridview.Rows[index].FindControl("DropDownList1");
                
        }
      

  2.   

    http://www.bbs180.com/topictag-16.aspx看一下吧,GridView专题。
      

  3.   

    参考:        protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
            {
                if (e.Row.RowType == DataControlRowType.DataRow)
                {
                    for (int i = 0; i < e.Row.Cells.Count; i++)
                    {
                        TableCell tc = e.Row.Cells[i];
                        foreach (Control c in tc.Controls)
                        {
                            if (c is DropDownList)
                            {
                                DropDownList ddl = c as DropDownList;
                                string columnName = GridView1.Columns[i].HeaderText;//columnName就是列名
                                //以下自己做绑定工作了
                            }
                        }
                    }
                }
            }