First , i want ask you excuses for my bad english.

Well, i'm a beginner in c# but i need it to my work in this time.

I have a SqlDataSource1 with "SELECT field1 from table1"
I have an Accordion linked with SqlDataSource1, and inside of Accordion1 i have a SqlDataSource2 with "Select field2 from table2 where id=!!!!! here i need use field1 from SqlDataSource1!!!!!!"

If i put in SqlDataSource2 a explicit value it run good. But i don`t get put like parameter in SqlDataSource2 the value of field1 of SqlDataSource1.

Field1 (value1)
Field2
Field2
Field1(value2)
Field2
Field2
Field2
...
...
The code:

<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:XEUSERACO %>"
ProviderName="<%$ ConnectionStrings:XEUSERACO.ProviderName %>"
OnSelecting="SqlDataSource1_Selecting"
SelectCommand="SELECT field1 from table1"
>


<cc1:Accordion ID="Accordion2" runat="server" SelectedIndex="0" FadeTransitions="true"
FramesPerSecond="40" TransitionDuration="250" AutoSize="None" [B]DataSourceID="SqlDataSource1"[/B] ContentCssClass="Content" HeaderCssClass="HEADER">
<HeaderTemplate>
<table border="1">
<tr>
<td>
[B]<%# Eval("Field1") %>[/B]

</td>
</tr>
</table>
</HeaderTemplate>
<ContentTemplate>
<table border="1">
<tr>
<td>
<asp:SqlDataSource ID="SqlDataSource2" runat="server"
ConnectionString="<%$ ConnectionStrings:XEUSERACO %>"
ProviderName="<%$ ConnectionStrings:XEUSERACO.ProviderName %>" OnSelecting="SqlDataSource2_Selecting"
SelectCommand="SELECT field2 from table2 where [B]id=!!!!here i need put param field1 rom SqlDataSource1!!!!!!"[/B] >


</asp:SqlDataSource>

<asp:Repeater runat="server" DataSourceID="SqlDataSource2" ID="articles">
<ItemTemplate>
[B]<%# Eval("field2") %>[/B]
</ItemTemplate>
</asp:Repeater>
</td>
</tr>
</table>
</ContentTemplate>
</cc1:Accordion>

Thank you very much.

If you are using sqldatasource control you need to set the select statment of the SqlDataSource2 like this:

SELECT field2 FROM table2 WHERE id = @id

And then when you want to populate your Accordion1 you need to do like this:

this.SqlDataSource2 .SelectParameters["id"].DefaultValue = "the value that you want in string of course";
            DataView dv = (DataView)this.SqlDataSource2.Select(DataSourceSelectArguments.Empty);

And then do what ever you like with DataView!

If you are using sqldatasource control you need to set the select statment of the SqlDataSource2 like this:

SELECT field2 FROM table2 WHERE id = @id

And then when you want to populate your Accordion1 you need to do like this:

this.SqlDataSource2 .SelectParameters["id"].DefaultValue = "the value that you want in string of course";
            DataView dv = (DataView)this.SqlDataSource2.Select(DataSourceSelectArguments.Empty);

And then do what ever you like with DataView!

Thanks, but the principal problem is how can i get the field1 value from SqlDataSource1 to put it in "the value that you want in string of course"?.
Kind Regards.
Thanks very much again.

Explain exactly what you want, and i mean post some code here and the structure of your DB so i will be able to help more.

Explain exactly what you want, and i mean post some code here and the structure of your DB so i will be able to help more.

If you was to Spain i invite you a full night of cups.:icon_smile:

In my .cs i have this:

protected void SqlDataSource2_Selecting(object sender, SqlDataSourceSelectingEventArgs e)
        {
   e.Command.CommandText = "SELECT field2 from table2 where id='" + p1 + "'";     
          
}

This code is executed for each row of SqlDataSource1 and if i put a fixed String in p1 it run well.

But i need put instead p1 the value of field1 from table1 of actually row of SqlDataSource1.

It's posible in this method get actually values from row of SqlDatasource1 to get the value of a field?.

Kind Regards again.

oK, it'is not solved, but i think that i'm guilty for my explication of the problem. So i'll open a new thread with a simple question.
Thanks very much all people who try to help me.

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.