如何获取gridView 中的dorpDownList 名称??
dropDownList 是gridView中的一模版列!!

解决方案 »

  1.   


    ((DropDownList)(gridView1.Rows[e.RowIndex].Cells[inedx].FindControl("DropDownList1"))).SelectedValue.ToString().Trim()
      

  2.   


    <asp:TemplateField HeaderText="DropDownList " HeaderStyle-BackColor="#8bb9ee">
                            <ItemTemplate>
                            <asp:DropDownList ID="DropDownList1" Width="120px" runat="server"></asp:DropDownList>
                            </ItemTemplate>
                    </asp:TemplateField>
      

  3.   

    string y = int.Parse(((DropDownList)GridView1.Rows[e.RowIndex].FindControl("ddlDepart")).ClientID);
      

  4.   


    <asp:TemplateField HeaderText="学历">
      <ItemTemplate>
         <%# Eval("xueliText")%>
           </ItemTemplate>
               <EditItemTemplate>
                 <asp:DropDownList ID="DDLXueli" runat="server" Width="90px" />
               </EditItemTemplate>
      <ItemStyle Width="100px" />
    </asp:TemplateField>
    string xueli = ((DropDownList)GridView1.Rows[e.RowIndex].FindControl("DDLXueli")).SelectedValue;
      

  5.   

    string xueli = (GridView1.Rows[e.RowIndex].FindControl("DDLXueli") as DropDownList).SelectedValue;
      

  6.   

    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) 

      if (e.Row.RowType == DataControlRowType.DataRow) 
      { 
        System.Data.DataRowView drv = (System.Data.DataRowView)e.Row.DataItem;    RadioButtonList rbl = (RadioButtonList)e.Row.FindControl("txtGender"); 
        if (rbl != null) 
        { 
          if ((bool)drv["Gender"]) 
          { 
            rbl.Items.FindByText("男").Selected = true; 
          } 
          else 
          { 
            rbl.Items.FindByText("女").Selected = true; 
          } 
        }     DropDownList ddl = (DropDownList)e.Row.FindControl("txtClassName"); 
        if (ddl != null) 
        { 
          ddl.Items.FindByValue(drv["ClassID"].ToString()).Selected = true; ///这是根据VALUE查找 
        } 
      } 

      

  7.   

    dorpDownList 名称是指什么?
      

  8.   

     名称当然是说他的ID
    string y = int.Parse(((DropDownList)GridView1.Rows[e.RowIndex].FindControl("ddlDepart")).ClientID);
      

  9.   


    1.当知道每一个DropDownList的Name的时候。
    string xueli = ((DropDownList)GridView1.Rows[e.RowIndex].FindControl("DropDownList1")).SelectedValue;或者(SelectedItem.Text)
    2.当不知道DropDownList的Name的时候。
     string xueli = ((DropDownList)GridView1.Rows[e.RowIndex].Controls[0]).SelectedValue;或者(SelectedItem.Text)