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
View all comments
Show parent comment
1
u/abuzzyisawesome Jan 24 '12 edited Jan 24 '12
Ok, I hate sounding like an idiot, I do apologize. Where does this code belong? I have an auto-generated data source and a bare bones gridview that I bind programmatically. I was attempting to add some code on the SelectedIndexChanged event to combine both methods in the response, but I get an empty page as my result. On my DetailsView.aspx, I have configured my datasource WHERE to pick up the QueryString("id") for my faccode parameter. Evidently, I am not posting the selected row right. Here is my SelectedIndexChanged. here is my [GridView] (http://i.imgur.com/scwdh.png) This is my datasource code on the search button click. Am I making this too hard? Thanks everyone for your patience with me.