protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)  
{  
  int Index=((GridViewRow)((DropDownList)sender).NamingContainer).RowIndex
  GridViewRow gvr = (sender as DropDownList).NamingContainer as GridViewRow;  
  if(gvr != null)  
  {   
  }  
}  
 
 

解决方案 »

  1.   

    int row = ((GridViewRow)((DropDownList)sender).NamingContainer).RowIndex;
    //获取行号
    int id=Convert.ToInt32(GridView1.DataKeys[row].Value);
     //此根据行号获取GridView中绑定数据库中的主键值string code = this.GridView1.Rows[row].Cells[0].Text;
    //获取该行第一个单元格的文本
      

  2.   

    感谢大家的回答,我已经解决了,方法是<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" 
                                onselectedindexchanged="DropDownList1_SelectedIndexChanged" DataKey='<%# Eval("OrderID") %>'>
                                <asp:ListItem Selected="True" Value="0">默认</asp:ListItem>
                                <asp:ListItem Value="1">已送出</asp:ListItem>
                                <asp:ListItem Value="2">已接收</asp:ListItem>
                            </asp:DropDownList>
    给DropDownList1设置一个属性并绑定到数据的主键,后台就可以这样string keyValue = dr.Attributes["DataKey"];访问了
      

  3.   

    再补充一个用 JS访问  <script type="text/javascript">
        function test(obj) {
        var a=obj.value;
        alert(a);
        if (a!="--请选择--") {
        alert( obj.parentNode.parentNode.childNodes.item(a).innerHTML );
        }
       
        }
        </script>
      

  4.   

    http://blog.csdn.net/xianfajushi/archive/2008/11/30/3413317.aspx