zoukankan      html  css  js  c++  java
  • 触发Repeater中的Dropdownlist的SelectedIndexChanged如何获得Repeater的当前行

     <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>                       
                           

    --------------------------------------------------------------


    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);

         
            //....下面写进数据库操作
          //....
           
        }

  • 相关阅读:
    分梨
    18岁生日
    马的移动
    摆积木
    杭电2093考试排名
    栈的应用——四则运算表达式求值
    用指针实现对二维数组元素的访问
    用多种方法访问字符数组元素
    fread()函数和fwrite()函数进行文件操作
    hdu-1431 素数回文
  • 原文地址:https://www.cnblogs.com/gdjlc/p/2086945.html
Copyright © 2011-2022 走看看