开发者

SQLDataSource inside an ASPxGridView - inject data through Eval()

I have an ASPX GridView with a DetailsRow which I need to display some information on the expanded row, as well as an opportunity to add some data. My problem right now is SELECT'ing the right data when the DetailsRow expands. This is my template code:

  <Templates>
       <DetailRow>
           <asp:Repeater DataSourceID="ConversationsDataSource" runat="server">
           <ItemTemplate>
           <p>Foobar</p>
           </ItemTemplate>
           </asp:Repeater>
           <asp:SqlDataSource SelectCommand='SELECT Subject, Message FROM [Fedmekirurgi].[dbo].[MessageSystem.Message] WHERE ConversationID = @ID %>'
                        runat="server" ID="ConversationsDataSource" ConnectionString="<%$ ConnectionStrings:Fedmekirurgi %>">
            <SelectParameters>
                <asp:Parameter Name="ID" Type="Int32" />
            </SelectParameters>
            </asp:SqlDataSource>
            <dx:ASPxMemo ID="ASPxMemo1" runat="server" Height="71px" Width="470px">
            </dx:ASPxMemo>
        </DetailRow>
   </Templates>

My problem is that I just for the life of me cannot get the relevant paramter injected into my SqlDataSource. Basically, if I could just do:

       开发者_开发知识库             <asp:SqlDataSource SelectCommand='SELECT Subject, Message FROM [Fedmekirurgi].[dbo].[MessageSystem.Message] WHERE ConversationID = <%# Eval("ID") %>'
                        runat="server" ID="ConversationsDataSource" ConnectionString="<%$ ConnectionStrings:Fedmekirurgi %>">

it would serve my needs!

So, how do I "inject" data I get from an Eval() into a SqlDataSource?


Not sure where that data is coming from but you have an option to pass parameters in SQLDataSource from QueryString, Cookie, Session, Form, Control, Route, and Profile For example, here's the SQLDataSource picking it up from the QueryString:

    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:ChinookConnectionString %>" 
        SelectCommand="SELECT [CustomerId], [FirstName], [LastName], [Country], [Phone], [Email] FROM [Customer] WHERE ([CustomerId] &gt;= @CustomerId)">
        <SelectParameters>
            <asp:QueryStringParameter DefaultValue="0" Name="CustomerId" 
                QueryStringField="custid" Type="Int32" />
        </SelectParameters>
    </asp:SqlDataSource>

As for passing the eval value on the client-side, I'm not sure that is possible because SQLDataSource is a server-control (I.e. runat=server) and it binds the data on the serverside before rendering it for the client browser.

For the Master-detail, check out these resources which can help you:

  • http://tv.devexpress.com/#ASPxGridView04
  • http://search.devexpress.com/?q=master-detail&p=T4|P5|57
  • http://documentation.devexpress.com/#AspNet/CustomDocument3773

Hope that helps, thanks.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜