Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
745
How to bind Record in webgrid action button click with sorting,paging,filtering
posted

Hi,

How to a bind Record to webgrid in button click event with sorting,paging,filtering,Grouping,Editing with code base..

Thanks in Advance

Karthik

Parents
  • 8736
    posted

    Hello karthi2itnet,

    The below markup and code behind will give more idea on how to bind grid on button click and on subsequent Ajax post back:

    HTML Mark up:

    <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
    <ig:WebDataGrid ID="WebDataGrid1" runat="server" Height="350px" Width="400px">
    </ig:WebDataGrid>
    <asp:Button ID="Button1" runat="server" Text="Bind Data" onclick="Button1_Click" />

    Code:

    protected void Page_Load(object sender, EventArgs e)
    {
    this.WebDataGrid1.DataSource = Session["data"];
    }
    protected DataTable getdata()
    {
    DataTable dt = new DataTable("Cutomer");
    dt.Columns.Add("ID", typeof(int));
    for (int i = 0; i < 10; i++)
    {
    dt.Rows.Add(i);
    }
    return dt;
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
    if (Session["data"] == null)
    {
    Session["data"] = getdata();
    }
    Setbehavior();
    this.WebDataGrid1.DataSource = Session["data"];
    }
    private void Setbehavior()
    {
    WebDataGrid1.Behaviors.CreateBehavior<Infragistics.Web.UI.GridControls.Sorting>();
    WebDataGrid1.Behaviors.CreateBehavior<Infragistics.Web.UI.GridControls.Paging>();
    WebDataGrid1.Behaviors.Paging.PageSize =5;
    WebDataGrid1.Behaviors.Paging.PagerMode = Infragistics.Web.UI.GridControls.PagerMode.NumericFirstLast;
    WebDataGrid1.Behaviors.CreateBehavior<Infragistics.Web.UI.GridControls.EditingCore>();
    WebDataGrid1.Behaviors.EditingCore.Behaviors.CreateBehavior<Infragistics.Web.UI.GridControls.CellEditing>();
    WebDataGrid1.Behaviors.EditingCore.Behaviors.CellEditing.EditModeActions.MouseClick = Infragistics.Web.UI.GridControls.EditMouseClickAction.Single;
    }

    For further details on how to add behavior at runtime please review relevant links from the link below:

    <http://help.infragistics.com/NetAdvantage/ASPNET/2011.2/CLR4.0/?page=WebDataGrid_Behaviors.html>

    I hope this helps.

Reply Children
No Data