Click here to Skip to main content
15,846,342 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a gridview. When i click on a particular row of gridview,I want to display that rows information in datalist. I dont want to use any extra select button or something for selecting the particular row.Just click on the row of grid.How can i do this?

Can this be done by using selected index changed event of grid or any other event?
Updated 26-Nov-13 0:26am
Karthik_Mahalingam 26-Nov-13 4:02am    
datalist is a data repeater control to display more than 1 items..
instead of datalist, you can use some container control to display the row data.
you can use javascript to do the above....


You can use JQuery to Append some Table or Div to show the details.

Add Click Event :[^]
Append DOM Object:[^]
Share this answer
Refer the This Link[^], there you will be demonstrated properly that how to bind you data list view by clickin on any row without auto generated select button. Further you can also visit this link[^] also.
Share this answer
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">
        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
            DataKeyNames="BookId" DataSourceID="SqlDataSource1">
                <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" />
        <asp:SqlDataSource ID="SqlDataSource1" runat="server"
            ConnectionString="<%$ ConnectionStrings:BookDetailConnectionString %>"
            SelectCommand="SELECT * FROM [Books]">

        <br />
        <asp:DataList ID="DataList1" runat="server" DataKeyField="BookId"
                <asp:Label ID="BookIdLabel" runat="server" Text='<%# Eval("BookId") %>' />
                <br />
                <asp:Label ID="BooknameLabel" runat="server" Text='<%# Eval("Bookname") %>' />
                <br />
                <asp:Label ID="PriceLabel" runat="server" Text='<%# Eval("Price") %>' />
                <br />
                <br />
        <asp:SqlDataSource ID="SqlDataSource2" runat="server"
            ConnectionString="<%$ ConnectionStrings:BookDetailConnectionString2 %>"
            SelectCommand="SELECT * FROM [Books] where Bookid=@bookid"  >

           <asp:ControlParameter ControlID="GridView1" Name="bookid" PropertyName="SelectedValue" />


Share this answer
pwavell 26-Nov-13 7:12am    
Dont want to use select button to select.just left click on grid row and data should display.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900