且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Asp.net GridView控件 - 数据绑定之前如何访问数据源?

更新时间:2023-10-07 11:06:04

是的,GridView.DataBinding事​​件将提高被绑定前的控制。您可以访问DataSource控件在该事件中,并进行修改,如果你愿意的话(例如,修改参数)。

Yes, the GridView.DataBinding event will be raised prior to the control being bound. You can access the DataSource control in that event and make modifications if you so desire (for example, modifying parameters).

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