如题

解决方案 »

  1.   

    比如怎么获得一个id是dropdownlist6的dropdownlist?
      

  2.   

    用户近控件拉到aspx页面上去时,也是如同标准控件一样,可以取得到的.
    不知楼主问题卡在哪里?
      

  3.   

    问题我没说清楚,我的
                <asp:TemplateField HeaderText="质量更改从">
                    <ItemTemplate>
                        <asp:DropDownList ID="DropDownList2" runat="server" 
    >
                        </asp:DropDownList>
                    </ItemTemplate>
    在一个griedview里面,运行后id被改了。
      

  4.   

        protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
    里可以
            string name = ((DropDownList)GridView1.Rows[e.RowIndex].FindControl("DropDownList4")).SelectedValue;
    但是    protected void OnSelectedIndexChanged(Object sender,EventArgs e)
    这里没有e.rowindex
      

  5.   

    遍历控件,如7楼所说,然后findcontrol["id"]
      

  6.   

    7楼的写法本身就有问题,首先我们要判断e.RowIndex是否合法,其次我们不能保证我们FindControl的结果!=null,这样直接.SelectedValue就会变成一个引用异常。正确的写法应该大致如下:
    以下代码来源MSDN:  void CustomersGridView_RowUpdating(Object sender, GridViewUpdateEventArgs e)
      {    // Iterate through the NewValues collection and HTML encode all 
        // user-provided values before updating the data source.
        foreach (DictionaryEntry entry in e.NewValues)
        {      e.NewValues[entry.Key] = Server.HtmlEncode(entry.Value.ToString());    }  }
          // Find control on page.
          Control myControl1 = FindControl("TextBox2");
          if(myControl1!=null)
      

  7.   

    我的代码不在CustomersGridView_RowUpdating里,而在OnSelectedIndexChanged里
      

  8.   

    protected void GridView1_RowUpdated(object sender, GridViewUpdatedEventArgs e)
        {
            string name = ((DropDownList)this.GridView1.SelectedRow.Cells[0].FindControl("DropDownList4")).SelectedValue; 
        }
      

  9.   

    不是rowupdating!!是OnSelectedIndexChanged!!!
      

  10.   

    rowupdating
    是抄你自己7楼的写法的,还以为你要在那里写嘛,呵呵,我也纳闷你怎么会在那里写。HOHO,找对了就好。
      

  11.   

    在GridView1_RowUpdating里可以用GridView1.Rows[e.RowIndex].找出是哪行的dropdownlist,在OnSelectedIndexChanged怎么找啊?这个OnSelectedIndexChanged是同一行的另外一个dropdownlist
      

  12.   

    现在得到同事建议,在“生成”个行的dropdownlist时加一个行数的属性。请问是什么事件啊?