As you click on select of gridview the selected row appears on datalist.
BookId Bookname Price
Select B1 Asp 1200
Select B2 Java 700
Select B3 C# 690
Select B4 PHP 659
Select B5 unix 865
BookId: B3
Bookname: C#
Price: 690
Use two sqldatasource control, sqldatasource for datalist must have parameterize select command, then set the selectparameters. Example shows every things below:
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataKeyNames="BookId" DataSourceID="SqlDataSource1">
<Columns>
<asp:CommandField ShowSelectButton="True" />
<asp:BoundField DataField="BookId" HeaderText="BookId" ReadOnly="True"
SortExpression="BookId" />
<asp:BoundField DataField="Bookname" HeaderText="Bookname"
SortExpression="Bookname" />
<asp:BoundField DataField="Price" HeaderText="Price" SortExpression="Price" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:BookDetailConnectionString %>"
SelectCommand="SELECT * FROM [Books]">
</asp:SqlDataSource>
<br />
<asp:DataList ID="DataList1" runat="server" DataKeyField="BookId"
DataSourceID="SqlDataSource2">
<ItemTemplate>
BookId:
<asp:Label ID="BookIdLabel" runat="server" Text='<%# Eval("BookId") %>' />
<br />
Bookname:
<asp:Label ID="BooknameLabel" runat="server" Text='<%# Eval("Bookname") %>' />
<br />
Price:
<asp:Label ID="PriceLabel" runat="server" Text='<%# Eval("Price") %>' />
<br />
<br />
</ItemTemplate>
</asp:DataList>
<asp:SqlDataSource ID="SqlDataSource2" runat="server"
ConnectionString="<%$ ConnectionStrings:BookDetailConnectionString2 %>"
SelectCommand="SELECT * FROM [Books] where Bookid=@bookid" >
<SelectParameters>
<asp:ControlParameter ControlID="GridView1" Name="bookid" PropertyName="SelectedValue" />
</SelectParameters>
</asp:SqlDataSource>
</div>
</form>