使用GridView进行用户控制

时间:2014-07-24 10:32:09

标签: c# asp.net .net gridview user-controls

我有一个带有单个GridView的用户控件。我已将数据表dtResult声明为静态以从页面获取它。现在,我有一种方法,例如。

protected void BindGridView()
{
    gvMyGrid.DataSource = dtResult; //this dtResult varies depending on the call of publicly exposed method of this user control.
    gvMyGrid.DataBind();
}

public void GetResult(string text)
{
    dtResult = new DataTable();
    dtResult = Getdata(text); //This method returns the collection by filtering it with text
    BindGridView();
}

public void GetResult()
{
    dtResult = new DataTable();
    dtResult = Getdata();
    BindGridView();
}

现在我可以轻松调用任何方法来绑定结果,但是我很难在分页后绑​​定相同的方法。如何记住最后一个被调用的方法,因为它可能是任何一个,我必须自动处理它,因为它在用户控件中。

请告知。

0 个答案:

没有答案