Asp.net GridView控件 - 数据绑定之前如何访问数据源? [英] Asp.net GridView - how to access datasource before data is bound?

查看:101
本文介绍了Asp.net GridView控件 - 数据绑定之前如何访问数据源?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想之前,我把它绑定到网格来访问数据源。我怎么做?我想我应该看起来像Grid.DataBinding事​​件

I'm trying to access datasource before I bind it to grid. How do I do that? My guess I should look in one of the events like Grid.DataBinding

推荐答案

是的,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";
}

这篇关于Asp.net GridView控件 - 数据绑定之前如何访问数据源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆