hi,

This is a bit complex..
I have 2 nested repeaters.. and 3 datasources(in markup)

<asp:SqlDataSource ID=data1 runat=server ConnectionString="<%$connectionstrings:MainServer %>" SelectCommand="select MatrixRiskFactorId,Name,MaxWeight from Matrixriskfactor" ></asp:SqlDataSource>

<asp:SqlDataSource ID=data2 runat=server ConnectionString="<%$connectionstrings:MainServer %>" SelectCommand="select * from MatrixQuestion" ></asp:SqlDataSource>

<asp:SqlDataSource ID=data3 runat=server ConnectionString="<%$connectionstrings:MainServer %>"  SelectCommand = "select MatrixRiskFactorId,Value,text from MatrixRiskFactorScore where MatrixRiskFactorId=2">


<repeater id=rep1 datasourceid=data1>
<itemtemplate>
<%# DataBinder.Eval(Container.DataItem, "Name")%>
<br/>

     <repeater id=rep2 datasourceid=data2>
     <headertemplate>
         <table>
             <th>Question</th><th>Score</th>
     <itemtemplate>
        <tr>
            <td>
            <%# DataBinder.Eval(Container.DataItem,"text") %>
            </td> 
            <td>
                <asp:RadioButtonList id=radiolist1 runat=server DataSourceID=data3 DataTextField="text" DataValueField="value" ></asp:RadioButtonList>

            </td>
        </tr>
     </ItemTemplate>

     <FooterTemplate>
        </table>

     </FooterTemplate>

     </itemtemplate>

</itemtemplate>



</repeater>

==================================================

as you can see in data3.. the where clause has a fixed value...(2)

I want to change it dynamiacally according to data1 or rep1 child control property...

i know its possible.. i just dont know how..?? :(

may be i'll have to add paramete.. but how do i set the parameter value to be depending on data1 or rep1 child control property ??

==================================================

Recommended Answers

All 3 Replies

Hi Instead of passing in a fixed datasource to your radio list you will have to dynamically set the the datasource.

You will need to use the ItemDataBound event of datarepeater 2 to capture the question value that you can then use to populate your answers. (It may be easier to "grab" the value of the question if you store it's ID in a hidden field you you can then pass into your answers query)

There is an example like this based on customers and products here: Nested ASP.NET DataRepeater

very helpful.. thanks a lot :)

No worries

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.