Issue with RADGrid

Philly picture Philly · May 20, 2010 · Viewed 7.1k times · Source

I Have radgrid in my page. When i turn off view state and in pageindexchanged event when click next page i am getting nothing. Simply a blank page. But when i turn on view state I am getting data in next pages. Is there any way to get the data. I cant turn on the view state due to performance issue. Please see the code below for the reference.

.aspx

    <telerik:RadGrid ID="RadGrid1" OnSortCommand="RadGrid1_SortCommand" OnPageIndexChanged="RadGrid1_PageIndexChanged"
        AllowSorting="True" PageSize="20" ShowGroupPanel="True" AllowPaging="True" AllowMultiRowSelection="True"
        AllowFilteringByColumn="true" AutoGenerateColumns="false" EnableViewState="false" runat="server" GridLines="None"
        OnItemUpdated="RadGrid1_ItemUpdated" OnDataBound="RadGrid1_DataBound">

aspx.cs

public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { LoadData(); }

private void LoadData()
{
    SqlConnection SqlConn = new SqlConnection("uid=tempuser;password=tempuser;data source=USWASHL10015\\SQLEXPRESS;database=CCOM;");
    SqlCommand cmd = new SqlCommand();
    cmd.Connection = SqlConn;
    cmd.CommandType = CommandType.StoredProcedure;
    cmd.CommandText = "usp_testing";
    SqlDataAdapter da = new SqlDataAdapter(cmd);
    DataSet ds = new DataSet();
    da.Fill(ds);
    RadGrid1.DataSource = ds;
    RadGrid1.DataBind();
    //RadGrid1.ClientSettings.AllowDragToGroup = true;
}

protected void RadGrid1_PageIndexChanged(object source, Telerik.Web.UI.GridPageChangedEventArgs e)
{
    //RadGrid1.Rebind();
    LoadData();
} 

Answer

Dick Lampard picture Dick Lampard · May 20, 2010

Try with advanced binding hooking the NeedDataSource grid event as shown on this sample: http://demos.telerik.com/aspnet-ajax/grid/examples/programming/needdatasource/defaultcs.aspx

Thus you should be able to page with viewstate off.

Dick