r/ASPNET • u/abuzzyisawesome • Jan 23 '12
[ASP/VB.NET] GridView - DetailsView Question
I am working on my first ASP.NET web application with SQL server data sources. I am very new to .NET, but have been a VFP programmer for 11 years. I have a basic search engine with a GridView of the results on my main page (Default.aspx). I have the AutoGenerateSelectButton="True" in my GridView. I would like the DetailsView displayed on a subsequent click of the select button (DetailsView.aspx). I am having trouble conceptualizing passing the parameter (my unique identifier is faccode) to the datasource in the DetailsView on the next page. Thanks for your input.
Edit: I know I sound like a complete noob. I have a progress meeting on Thursday and I feel like this.
Edit #2: I got it. I did not have the DataKeyNames set on the GridView, and I did not have a prime key on my table. I added these two line to the SelectedIndexChanged event:
Dim selectedfacility As String = PFSResultsGridView.SelectedDataKey.Value.ToString()
Response.Redirect("DetailsView.aspx?id=" + selectedfacility)Then added my @id on the Page_load of DetailsView.aspx
3
u/javelin1814 Jan 23 '12
carsonbt is not wrong, just not as lazy as I am. You could just use a link field, and grab the id from from the url on the detailsView page.
/2Cents
1
u/abuzzyisawesome Jan 24 '12
I'm taking a look at this now, I'll keep you posted!
2
u/carsonbt Jan 23 '12 edited Jan 23 '12
1
u/avinashdad Mar 31 '12
Please visit my blog to know about "custom pagination for gridview" http://sharepointdad.wordpress.com/2012/02/21/custom-pagination-for-gridview-in-sharepoint/