如果不使用任何实例成员,我可以在ASP.NET Pages和UserControls类中使用静态方法吗?即:
@H_502_2@protected void gridView_PageIndexChanging(object sender,GridViewPageEventArgs e)
{
gridStatement.DataSource = CreateDataSource();
gridStatement.PageIndex = e.NewPageIndex;
gridStatement.DataBind();
}
private static DataTable CreateDataSource()
{
using (var command = new sqlCommand("SELECT foobar"))
{
var table = new DataTable();
new sqlDataAdapter(command).Fill(table);
return table;
}
}
或者这不是线程安全的?