Asp.net GridView - how to access data source before data binding?

I am trying to access a data source before binding it to the grid. How can I do it? My guess is that I should look at one of events like Grid.DataBinding

+2
source share
2 answers

Yes, the GridView.DataBinding event will be raised before the control binds. You can access the DataSource control in this case and make changes if you wish (for example, changing parameters).

protected void Grid_DataBinding(object sender, EventArgs e)
{
  mySqlDataSource.SelectCommand = "Select * from Stars";
}
+1
source

- . page_load , datagrid. , .

, !

0

All Articles