如何在父中继器中找到当前的中继器行?

时间:2010-03-04 08:02:56

标签: c# asp.net

<asp:Repeater ID="rp1" runat="server">
        <ItemTemplate>
            <ul>
                <li>
                    <%#Module(Convert.ToInt32(Eval("id")),Eval("university").ToString()) %>
                    <asp:Repeater ID="rp2" runat="server">
                    <ItemTemplate>
                    <ol>
                    <li id="sublist" runat="server">
                    <%#Eval("college") %>
                    </li>
                    </ol>
                    </ItemTemplate>
                    </asp:Repeater>
                </li>
            </ul>
        </ItemTemplate>
    </asp:Repeater>

C#CODE

public string Module(int id,string university)
    {
        con = new SqlConnection(ConStr);
        con.Open();
        cmd = new SqlCommand("SELECT college FROM tbluniversity where id=" + id, con);
        da = new SqlDataAdapter(cmd);
        con.Close();
        ds = new DataSet();
        da.Fill(ds);


//Here I want to find the inner repeator of current row then bind this dataset to that.
how to find Repeator


        return university;
    }

1 个答案:

答案 0 :(得分:1)

你必须添加一个ItemCreated事件,你可以使用e.Item.FindControl方法找到你的内部转发器使用它的id