Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Please How can I show what is selected on the grid view to the details view
I have a drop down link for search
first on on btn_Search
it query the  the database and populate the information on the grid view
// gridview.datasource = null;
gridview.databind();
datatable dt  = me.query("select * from law where id = '" + drpL.selectedvalue +"'");
if (dt.rows.count > 0 )
{
gridview.datasource  =  dt
detailsview.datasource = dt
gridview.databind();
detailsview.databind();
}

// that is my select statement, I enabled selection...onselectedindexchanged="GridView_SelectedIndexChanged"
/*
My question is How do i on the code view write a simple code that will enable me to select a row and it will appear on the details view?

protected void GridView_SelectedIndexChanged(object sender, EventArgs e)
    {
        
    }

Can Some one help me out on this..
thanks
*/
Posted

1 solution

you can Get the currently selected row using the SelectedRow property.
GridViewRow row = GridView.SelectedRow;

and then get the required value from row using
MessageLabel.Text = "You selected " + row.Cells[2].Text + ".";

have a look at http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.selectedindexchanged.aspx[^]
 
Share this answer
 
Comments
Difameg Network Nigeria 1-Aug-13 11:35am    
thank you but I have done that before, I want the selected value to Bind on a Detail view
Could you please help me on the code?
[no name] 1-Aug-13 12:13pm    
get the ID of row to show in the DetailsView. Then query for the data and bind to the DetailsView.

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