触发Repeater中的Dropdownlist的SelectedIndexChanged如何获得Repeater的当前行

.aspx

 <asp:Repeater ID="rptUserList" runat="server" OnItemCommand="rptUserList_ItemCommand">
  <ItemTemplate>
    <tr>
      <td>
          <asp:CheckBox ID="chkDel" runat="server" />
        </td>                                                             
        <td style="word-break: break-all" align="center">
            <asp:Literal runat="server" ID="ltlId" Text=' <%#Eval("Id")%>' Visible="false"> </asp:Literal>         
            <%# Eval("UserName")%>
        </td>         
        <td>
          <asp:DropDownList ID="ddlRole" runat="server"AutoPostBack="true"OnSelectedIndexChanged="ddlRole_SelectedIndexChanged"></asp:DropDownList>                    </td>  
.aspx.cs                
protected void ddlRole_SelectedIndexChanged(object sender, EventArgs e)
    {
      // Response.Write(((DropDownList)sender).SelectedValue);

        DropDownList ddlRole = (DropDownList)sender;
        int roleId = Convert.ToInt32(ddlRole.SelectedValue);

        Repeater rptUserList = ddlRole.Parent.Parent as Repeater;
        int n = ((RepeaterItem)ddlRole.Parent).ItemIndex;       
        int Id = Convert.ToInt32(((Literal)(rptUserList.Items[n].FindControl("ltlId"))).Text);
     
        //....下面写进数据库操作
      //....
       
    }

你可能感兴趣的:(数据库,object,server,asp)