我希望能够将参数传递给grid_NeedDataSource。
RadGrid.NeedDataSource += new GridNeedDataSourceEventHandler(grid_NeedDataSource(Parameter i want to pass));
void grid_NeedDataSource(object sender, GridNeedDataSourceEventArgs e, DataTable dt)
{
DataTable current = dt;
RadGrid grid = (RadGrid)sender;
grid.DataSource = current;
}
我希望能够将DataTable作为参数传递给它。我怎么能这样做?
答案 0 :(得分:0)
试试这个:
Radgrid1.NeedDataSource += new GridNeedDataSourceEventHandler((sender, e) => grid_NeedDataSource(sender, e, "new parameter"));
protected void grid_NeedDataSource(object sender, GridNeedDataSourceEventArgs e, string t)
{
}
修改:要传递DataTable
,您可以这样做:
DataTable dt=new DataTable();
Radgrid1.NeedDataSource += new GridNeedDataSourceEventHandler((sender, e) => grid_NeedDataSource(sender, e, dt));
protected void grid_NeedDataSource(object sender, GridNeedDataSourceEventArgs e, DataTable t)
{
}