Ed
asked on
Change datasource of gridview on postback
How do I change the gridview datasource in an if statement
this is as far as i've got.
Protected Sub ddlCountry_SelectedIndexCh anged(ByVa l sender As Object, ByVal e As System.EventArgs) Handles ddlCountry.SelectedIndexCh anged
If ddlCountry.Text = "All" Then
GridView1.DataSourceID = dsCategoryAll
End If
End Sub
this is as far as i've got.
Protected Sub ddlCountry_SelectedIndexCh
If ddlCountry.Text = "All" Then
GridView1.DataSourceID = dsCategoryAll
End If
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
commment id: 24747683 should solve the problem.
no new form the asker.
no new form the asker.
(A) Datasource : the one which holds records, could be dataset, dropdownlist, arrays etc. Assigned to controls (e.g. Grid view) like Gridview1.Datasource= your datasource
(B) DataBind : Binding database to controls which is Gridview1.DataBind
Now you wish to change the datasource on postback. So if that changes on first time page load you would get your (old) datasource and after then page loads you would get your (new) datasource. Is that what you wished? If no, then please explain or post your code or any link which justified your example. I'm asking such long questions, as this is quite rare of changing datasource and that too on postbacks
thanks