[2005] Gridview Datasource
Hi there, I have got a web-page with a grid view on it, initially there is no data source bound to the grid ... When I press a button, I want the datasource to be set, now I tried the following code but absolutely nothing happens ... where's the mistake that I'm making ... ?
Code:
Protected Sub ButtonSelectCourse_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ButtonSelectCourse.Click
Label1.Text = "RadioButton1"
GridView1.DataSource = AccessDataSourceFDES1
GridView1.DataBind()
GridView1.Visible = True
Dim n As Integer = GridView1.Rows.Count
End Sub
where I say "Dim n as integer = Gridview1.Rows.Count", I just used that to see if there was infact any changes made and the grid was maybe invisible or something, but the count is 0 ...
Re: [2005] Gridview Datasource
hmmm... i've never tried anything like this, but i do have a suggestion.
instead of:
GridView1.DataSource = AccessDataSourceFDES1
GridView1.DataBind()
try this:
GridView1.DataSourceID = "AccessDataSourceFDES1"
GridView1.DataBind()
because i assume that AccessDataSourceFDES1 is an actual DataSource object on your page and not something you are creating programmatically.
Re: [2005] Gridview Datasource
Yes it is an actual DataSource lying on the page, but the ID thing doesn't work either, and I know the DataSource contains Data ... 12 rows of it ...
Re: [2005] Gridview Datasource
Seeing that that way of doing it doesn't really want to work ... how about this ... Is there a way to change the Datasource's query and then just refresh the Gridview?
Re: [2005] Gridview Datasource
but to change the query realtime ... (while the page is open) ... so if a user clicks on a button it changes the query and refreshes the grid ...
Re: [2005] Gridview Datasource
While this isn't a proper solution to your question, what happens when you attempt to create a regular dataset and bind the gridview to that dataset?
Re: [2005] Gridview Datasource
I have found another way ... Each time another option is taken, instead of trying to bind another datasource to it, I just change the Select Query and then DataBind it again ... because they all come from the same database, they just have different queries ...