I have a gridview that is populating with Provider information, like name and title, and hiding the ID column. This works fine. However, I have a filter and that filter actually works also, but I want to go and select say the second person in the filtered
list, and it is coming back with the ID of that original list from Row(1). Here is a quick dirty example:
ORIGINAL LIST ON LOAD
PROVIDERS (ID-hidden)
Select Smith, Joe, MD 1
Select Jones, Janet, PCA 2
Select Medic, Doctor, MD 3
Select Doe, Allison, PCA 4
FILTERED LIST
Select Smith, Joe, MD 1
Select Doe, Allison, PC 4
However, if I select Allison Doe from the filtered list, I get the ID for Janet Jones (2 and not 4).
Structured, it is a page that has three gridviews: one for providers, then specialties, and finally locations. I want the end user to be able to select a provider, and then filter specialty and location; select specialty, and then filter provider, locations;
or select location and list providers, specialties.
I am not even getting the row index, Here is the code that is "storing" that ID
Dim selectedRow As GridViewRow = gvProviders.SelectedRow
SelectedProviderID = gvProviders.SelectedRow.Cells.Item(1).Text
And when stepping through the code the selectedRow does reflect the proper cells AND Item(1) is the ID of the correct provider, but it is returning the ID of the row of the prior table data.
I am not even getting the row index, Here is the code that is "storing" that ID
Dim selectedRow As GridViewRow = gvProviders.SelectedRow
SelectedProviderID = gvProviders.SelectedRow.Cells.Item(1).Text
And when stepping through the code the selectedRow does reflect the proper cells AND Item(1) is the ID of the correct provider, but it is returning the ID of the row of the prior table data.
I can only assume you are mistaken or there are other issues with the code. Keep in mind, that we can only see the code you share on the forum. Post all the relevant code if you need community debugging support.
Thanks for the response. When you mentioned logic error, it made me step through the code (F8), step by step and I found that I forgot the statement in Form_Load If Not IsPostBack, so it kept running the original form load list on a button click or a select
link. However, once I put this in, it is functioning as to be expected.
Member
104 Points
283 Posts
Baffled by ID selection in GridView
Aug 13, 2019 12:29 PM|guyinkalamazoo|LINK
I have a gridview that is populating with Provider information, like name and title, and hiding the ID column. This works fine. However, I have a filter and that filter actually works also, but I want to go and select say the second person in the filtered list, and it is coming back with the ID of that original list from Row(1). Here is a quick dirty example:
ORIGINAL LIST ON LOAD
PROVIDERS (ID-hidden)
Select Smith, Joe, MD 1
Select Jones, Janet, PCA 2
Select Medic, Doctor, MD 3
Select Doe, Allison, PCA 4
FILTERED LIST
Select Smith, Joe, MD 1
Select Doe, Allison, PC 4
However, if I select Allison Doe from the filtered list, I get the ID for Janet Jones (2 and not 4).
Structured, it is a page that has three gridviews: one for providers, then specialties, and finally locations. I want the end user to be able to select a provider, and then filter specialty and location; select specialty, and then filter provider, locations; or select location and list providers, specialties.
Thanks for any insight
All-Star
53051 Points
23634 Posts
Re: Baffled by ID selection in GridView
Aug 13, 2019 12:44 PM|mgebhard|LINK
You have logical bugs in your code. It seems you are using a row index as the record ID.
Member
104 Points
283 Posts
Re: Baffled by ID selection in GridView
Aug 13, 2019 12:50 PM|guyinkalamazoo|LINK
I am not even getting the row index, Here is the code that is "storing" that ID
And when stepping through the code the selectedRow does reflect the proper cells AND Item(1) is the ID of the correct provider, but it is returning the ID of the row of the prior table data.
All-Star
53051 Points
23634 Posts
Re: Baffled by ID selection in GridView
Aug 13, 2019 01:03 PM|mgebhard|LINK
I can only assume you are mistaken or there are other issues with the code. Keep in mind, that we can only see the code you share on the forum. Post all the relevant code if you need community debugging support.
Member
104 Points
283 Posts
Re: Baffled by ID selection in GridView
Aug 13, 2019 01:56 PM|guyinkalamazoo|LINK
Thanks for the response. When you mentioned logic error, it made me step through the code (F8), step by step and I found that I forgot the statement in Form_Load If Not IsPostBack, so it kept running the original form load list on a button click or a select link. However, once I put this in, it is functioning as to be expected.