This is a migrated thread and some comments may be shown as answers.

gridview vs radgrid

4 Answers 196 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Raj
Top achievements
Rank 1
Raj asked on 02 Jul 2010, 02:45 AM
Dear Telerik team,

I am migrating gridview to radgrid. I am working on updating my radgrid rows where I am getting some issues.

I updating Clarify Account Nbr, site id, Quote ID columns in "Inplace" editmode. Lets say before update my values are 200, 300, 400 for columns  Clarify Account Nbr, site id, Quote ID. When i click edit button and change the values to 111, 222, 333. when I am debugging my code and trying to see the textbox.text values  It is showing the old values(200, 300, 400) not the new values (111, 222, 333). ( I hope you guys are understand my problem). Where I am doing wrong. Please help me.
I saw this link but no use.

http://www.telerik.com/community/forums/aspnet-ajax/grid/radgrid-vs-gridview.aspx

In the below code if you see

string ClarifyAccountNbr = (editedItem["Clarify Account Nbr"].Controls[0] as TextBox).Text;
        string SiteID = (editedItem["Site ID"].Controls[0] as TextBox).Text;
        string QuoteID = (editedItem["Quote ID"].Controls[0] as TextBox).Text;

when i am debugging and pointing to ClarifyAccountNbr, SiteID, QuoteID I am getting older values not new values.( before updating)

Here is my code

<table style="width: 98%">  
            <tr> 
                <td colspan="2">  
                    <asp:Label runat="server" Font-Bold="true" Font-Size="14pt" ID="lblTskName"></asp:Label> 
                </td> 
            </tr> 
            <tr> 
                <td colspan="2">  
                    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">  
                    </telerik:RadScriptManager> 
                    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">  
                        <ClientEvents OnRequestStart="onRequestStart" /> 
                        <AjaxSettings> 
                            <telerik:AjaxSetting AjaxControlID="rg200">  
                                <UpdatedControls> 
                                    <telerik:AjaxUpdatedControl ControlID="rg200" LoadingPanelID="RadAjaxLoadingPanel1" /> 
                                </UpdatedControls> 
                            </telerik:AjaxSetting> 
                        </AjaxSettings> 
                    </telerik:RadAjaxManager> 
                    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Skin="Default">  
                    </telerik:RadAjaxLoadingPanel> 
                    <telerik:RadGrid ID="rg200" runat="server" AutoGenerateColumns="False" PageSize="30" 
                        Height="550px" OnNeedDataSource="rg200_NeedDataSource" Width="100%" AllowPaging="True" 
                        AllowSorting="True" AllowMultiRowSelection="True" EnableHeaderContextMenu="True" 
                        GridLines="None" EnableHeaderContextFilterMenu="True" AllowMultiRowEdit="True" 
                        AllowFilteringByColumn="True" OnPreRender="rg200_PreRender" OnItemCreated="rg200_ItemCreated" 
                        EnableViewState="False" OnUpdateCommand="rg200_UpdateCommand">  
                        <HeaderStyle Height="20px" BackColor="#004000" Font-Size="8pt" Font-Bold="True" ForeColor="White" 
                            HorizontalAlign="Center" BorderColor="White" BorderWidth="1px" /> 
                        <ExportSettings IgnorePaging="true" ExportOnlyData="true">  
                            <Pdf AllowModify="false" AllowPrinting="true" PageBottomMargin="" PageFooterMargin="" 
                                PageHeaderMargin="" PageHeight="11in" PageLeftMargin="" PageRightMargin="" PageTopMargin="" 
                                PageWidth="14in" /> 
                        </ExportSettings> 
                        <MasterTableView GridLines="None" DataKeyNames="orderId" CommandItemDisplay="Top" 
                            EditMode="InPlace">  
                            <CommandItemSettings ShowExportToWordButton="true" ShowExportToExcelButton="true" 
                                ShowExportToCsvButton="true" ShowExportToPdfButton="true" ShowAddNewRecordButton="false" /> 
                            <Columns> 
                                <telerik:GridClientSelectColumn UniqueName="ClientSelectColumn" HeaderStyle-Width="3%" 
                                    ItemStyle-Width="3%">  
                                    <HeaderStyle Width="3%"></HeaderStyle> 
                                    <ItemStyle Width="3%"></ItemStyle> 
                                </telerik:GridClientSelectColumn> 
                                <telerik:GridBoundColumn UniqueName="sId" HeaderText="sId" DataField="sId" Visible="false">  
                                </telerik:GridBoundColumn> 
                                <telerik:GridBoundColumn UniqueName="orderId" HeaderText="orderId" DataField="orderId">  
                                </telerik:GridBoundColumn> 
                                <telerik:GridBoundColumn UniqueName="Customer Name" HeaderText="Customer Name" DataField="Customer Name" 
                                    ReadOnly="true">  
                                </telerik:GridBoundColumn> 
                                <telerik:GridBoundColumn UniqueName="Market Name" HeaderText="Market Name" DataField="Market Name" 
                                    ReadOnly="true">  
                                </telerik:GridBoundColumn> 
                                <telerik:GridBoundColumn UniqueName="LOB" HeaderText="LOB" DataField="LOB" ReadOnly="true">  
                                </telerik:GridBoundColumn> 
                                <telerik:GridBoundColumn UniqueName="Headend Name" HeaderText="Headend Name" DataField="Headend Name" 
                                    ReadOnly="true">  
                                </telerik:GridBoundColumn> 
                                <telerik:GridBoundColumn UniqueName="Project Name" HeaderText="Project Name" DataField="Project Name" 
                                    ReadOnly="true">  
                                </telerik:GridBoundColumn> 
                                <telerik:GridBoundColumn UniqueName="Site Name" HeaderText="Site Name" DataField="Site Name" 
                                    ReadOnly="true">  
                                </telerik:GridBoundColumn> 
                                <telerik:GridBoundColumn UniqueName="Task Status" HeaderText="Task Status" DataField="Task Status" 
                                    ReadOnly="true">  
                                </telerik:GridBoundColumn> 
                                <telerik:GridBoundColumn UniqueName="Clarify Account Nbr" HeaderText="Clarify Account Nbr" 
                                    DataField="Clarify Account Nbr">  
                                </telerik:GridBoundColumn> 
                                <telerik:GridBoundColumn UniqueName="Site ID" HeaderText="Site ID" DataField="Site ID">  
                                </telerik:GridBoundColumn> 
                                <telerik:GridBoundColumn UniqueName="Quote ID" HeaderText="Quote ID" DataField="Quote ID">  
                                </telerik:GridBoundColumn> 
                                <telerik:GridCheckBoxColumn UniqueName="EDP Created?" HeaderText="EDP Created?" DataField="EDP Created?">  
                                </telerik:GridCheckBoxColumn> 
                                <telerik:GridEditCommandColumn UniqueName="ECC200">  
                                </telerik:GridEditCommandColumn> 
                            </Columns> 
                            <PagerStyle AlwaysVisible="True"></PagerStyle> 
                        </MasterTableView> 
                        <ClientSettings EnableRowHoverStyle="true" ReorderColumnsOnClient="false" AllowDragToGroup="false" 
                            AllowColumnsReorder="True">  
                            <Scrolling AllowScroll="true" EnableVirtualScrollPaging="false" UseStaticHeaders="true" /> 
                            <Selecting AllowRowSelect="True"></Selecting> 
                            <Resizing AllowRowResize="true" AllowColumnResize="True" EnableRealTimeResize="True" 
                                ResizeGridOnColumnResize="False"></Resizing> 
                        </ClientSettings> 
                        <PagerStyle Mode="NextPrevAndNumeric" AlwaysVisible="true"></PagerStyle> 
                    </telerik:RadGrid> 
                </td> 
            </tr> 
            <tr> 
                <td colspan="2">  
                    &nbsp;  
                </td> 
            </tr> 
        </table> 

.cs file

public partial class Tak200 : System.Web.UI.Page  
{  
    protected void Page_Load(object sender, EventArgs e)  
    {  
        try  
        {  
            if (!IsPostBack)  
            {  
                Session["SearchRes"] = null;  
                if (Session["TaskName"] != null)  
                    lblTskName.Text = Session["TaskName"].ToString();  
                Session["FilColms"] = null;  
                Session["SortExp"] = null;  
                Session["FilExp"] = null;  
                Session["ViewAll"] = null;  
                BindGrid();  
            }  
        }  
        catch (Exception ex)  
        {  
            throw ex;  
        }  
    }  
 
    private void BindGrid()  
    {  
        try  
        {  
            DataSet dsResult = new DataSet();  
 
            clsSearch_BL clsObj = new clsSearch_BL();  
            clsObj.TaskID = (string)Session["TaskID"];  
            clsObj.CustName = (string)Session["CustName"];  
            clsObj.MarketName = (string)Session["MarketName"];  
            clsObj.HeadendName = (string)Session["HeadendName"];  
            clsObj.SiteName = (string)Session["SiteName"];  
            clsObj.TaskStatus = (string)Session["TaskStatus"];  
            clsObj.OrdType = (string)Session["OrdType"];  
            clsObj.OrdStatus = (string)Session["OrdStatus"];  
            clsObj.ProName = (string)Session["ProName"];  
            clsObj.LOC = (string)Session["LOC"];  
            clsObj.QuoteID = (string)Session["QuoteID"];  
            clsObj.CMNumber = (string)Session["CMNumber"];  
 
            if (Session["SearchRes"] == null)  
            {  
                dsResult = clsObj.getSearchResults_BL(clsObj);  
                Session["SearchRes"] = dsResult;  
            }  
            else  
                dsResult = (DataSet)Session["SearchRes"];  
 
            DataView dataView = dsResult.Tables[0].DefaultView;  
            rg200.DataSource = dsResult;  
            //rg200.DataBind();  
        }  
        catch (Exception ex)  
        {  
            throw ex;  
        }  
    }  
 
    protected void rg200_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)  
    {  
        BindGrid();  
    }  
 
    protected void rg200_PreRender(object sender, EventArgs e)  
    {  
        rg200.MasterTableView.GetColumnSafe("RowIndicator").Display = false;  
 
    }  
 
    protected void rg200_ItemCreated(object sender, GridItemEventArgs e)  
    {  
        if (e.Item is GridPagerItem)  
        {  
            RadComboBox combo = (e.Item as GridPagerItem).FindControl("PageSizeComboBox") as RadComboBox;  
 
            // The number of items shown when all is selected   
            int allRowsCount = int.MaxValue;  
 
            // Remove duplicates   
            RadComboBoxItem duplicate = combo.Items.FindItemByValue(allRowsCount.ToString());  
            if (duplicate != null)  
            {  
                duplicate.Remove();  
            }  
 
            // Create a new item for showing all   
            RadComboBoxItem item = new RadComboBoxItem("All", allRowsCount.ToString());  
            item.Attributes.Add("ownerTableViewId", e.Item.OwnerTableView.ClientID);  
            combo.Items.Add(item);  
 
            // Set the current pagesize as the selected value   
            combo.Items.FindItemByValue(rg200.PageSize.ToString()).Selected = true;  
        }  
    }  
 
    protected void rg200_UpdateCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)  
    {  
        int intTskID = Convert.ToInt16(Session["TaskID"]);  
 
        GridEditableItem eeditedItem = e.Item as GridEditableItem;  
        //Get the primary key value using the DataKeyValue.        
        string Id = editedItem.OwnerTableView.DataKeyValues[editedItem.ItemIndex]["orderId"].ToString();  
        //Access the textbox from the edit form template and store the values in string variables.  
        string ClarifyAccountNbr = (editedItem["Clarify Account Nbr"].Controls[0] as TextBox).Text;  
        string SiteID = (editedItem["Site ID"].Controls[0] as TextBox).Text;  
        string QuoteID = (editedItem["Quote ID"].Controls[0] as TextBox).Text;  
        CheckBox chkEDP = (editedItem["EDP Created?"].Controls[0] as CheckBox);  
      }  

4 Answers, 1 is accepted

Sort by
0
Veli
Telerik team
answered on 06 Jul 2010, 01:56 PM
Hello Raj,

The code you provided seems fine. Here are a couple of suggestions you can try:

1. Do not bind the grid explicitly in Page_Load. Providing an event handler for RadGrid's NeedDataSource event should suffice. RadGrid will automatically fire this event when it needs to rebind and you can set its data source in it only.

2. Use the column editors to get the edited fields:

protected void rg200_UpdateCommand(object source, Telerik.Web.UI.GridCommandEventArgs e) 
    int intTskID = Convert.ToInt16(Session["TaskID"]); 
 
    GridEditableItem eeditedItem = e.Item as GridEditableItem; 
    //Get the primary key value using the DataKeyValue.       
    string Id = editedItem.OwnerTableView.DataKeyValues[editedItem.ItemIndex]["orderId"].ToString(); 
    //Access the textbox from the edit form template and store the values in string variables. 
     
    string ClarifyAccountNbr = ((GridTextBoxColumnEditor)editItem.EditManager.GetColumnEditor("Clarify Account Nbr")).TextBoxControl.Text;
 
    string SiteID = ((GridTextBoxColumnEditor)editItem.EditManager.GetColumnEditor("Site ID")).TextBoxControl.Text;
 
    string QuoteID = ((GridTextBoxColumnEditor)editItem.EditManager.GetColumnEditor("Quote ID")).TextBoxControl.Text;
 
    CheckBox chkEDP = ((GridCheckBoxColumnEditor)editItem.EditManager.GetColumnEditor("EDP Created?")).CheckBoxControl;
  }

Using the column editors in this way should give  you the most up to date values in the fields of the edited item. If they are the same, this means RadGrid has rebound before the UpdateCommand has fired, the edited item is recreated and the edited values are gone. If this is the case, you need to double-check your binding and make sure RadGrid is not rebound preliminarily.

Kind regards,
Veli
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Raj
Top achievements
Rank 1
answered on 06 Jul 2010, 06:24 PM
HI veli,

I removed onnneddatasource event and bind the data in pageload and bindgrid method then its working fine. One more issue is after updating, the rows or columns are still displaying in editmode. How to remove that editmode after updating.  and the paging is also not working. when i click the next page its diplaying nothing( i have enableviewstate in false mode)
protected void rg200_UpdateCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)  
    {  
 
        if (Session["TaskID"] != null)  
        {  
            string strTaskID = (string)Session["TaskID"];  
            if (strTaskID != string.Empty)  
            {  
                clsTaskUpdates_BL objBL = new clsTaskUpdates_BL();  
 
                GridEditableItem eeditedItem = e.Item as GridEditableItem;  
                //Get the primary key value using the DataKeyValue.        
                string OrdID = editedItem.OwnerTableView.DataKeyValues[editedItem.ItemIndex]["orderId"].ToString();  
                //Access the textbox from the edit form template and store the values in string variables.  
 
                string ClarifyAccountNbr = ((GridTextBoxColumnEditor)editedItem.EditManager.GetColumnEditor("Clarify Account Nbr")).TextBoxControl.Text;  
 
                string SiteID = ((GridTextBoxColumnEditor)editedItem.EditManager.GetColumnEditor("Site ID")).TextBoxControl.Text;  
 
                string QuoteID = ((GridTextBoxColumnEditor)editedItem.EditManager.GetColumnEditor("Quote ID")).TextBoxControl.Text;  
 
                CheckBox chkEDP = ((GridCheckBoxColumnEditor)editedItem.EditManager.GetColumnEditor("EDP Created?")).CheckBoxControl;  
 
                //string ClarifyAccountNbr = (editedItem["Clarify Account Nbr"].Controls[0] as TextBox).Text;  
                //string SiteID = (editedItem["Site ID"].Controls[0] as TextBox).Text;  
                //string QuoteID = (editedItem["Quote ID"].Controls[0] as TextBox).Text;  
                //CheckBox chkEDP = (editedItem["EDP Created?"].Controls[0] as CheckBox);  
                try  
                {  
                    objBL.setTask200_Bl(OrdID, ClarifyAccountNbr, SiteID, QuoteID, chkEDP.Checked);  
                    Session["SearchRes"] = null;  
                     
                    BindGrid();  
 
                }  
                catch (Exception ex)  
                {  
                    rg200.Controls.Add(new LiteralControl("Unable to update Employee. Reason: " + ex.Message));  
                    e.Canceled = true;  
                }  
            }  
        }  
    } 


    protected void rg200_PageIndexChanged(object source, GridPageChangedEventArgs e)  
    {  
        try  
        {  
            rg200.CurrentPageIndex = e.NewPageIndex;  
            BindGrid();  
        }  
        catch (Exception ex)  
        {  
            throw ex;  
        }  
    } 


                    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">  
                        <ClientEvents OnRequestStart="onRequestStart" /> 
                        <AjaxSettings> 
                            <telerik:AjaxSetting AjaxControlID="rg200">  
                                <UpdatedControls> 
                                    <telerik:AjaxUpdatedControl ControlID="rg200" LoadingPanelID="RadAjaxLoadingPanel1" /> 
                                    <telerik:AjaxUpdatedControl ControlID="RadMenu1" /> 
                                </UpdatedControls> 
                            </telerik:AjaxSetting> 
                            <telerik:AjaxSetting AjaxControlID="RadMenu1">  
                                <UpdatedControls> 
                                    <telerik:AjaxUpdatedControl ControlID="rg200" LoadingPanelID="RadAjaxLoadingPanel1" /> 
                                    <telerik:AjaxUpdatedControl ControlID="RadMenu1" /> 
                                </UpdatedControls> 
                            </telerik:AjaxSetting> 
                        </AjaxSettings> 
                    </telerik:RadAjaxManager> 
                    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Skin="Default">  
                    </telerik:RadAjaxLoadingPanel> 
                    <input type="hidden" id="radGridClickedRowIndex" name="radGridClickedRowIndex" /> 
                    <telerik:RadGrid ID="rg200" runat="server" AutoGenerateColumns="False" PageSize="30" 
                        Height="550px" Width="100%" AllowPaging="True" AllowSorting="True" AllowMultiRowSelection="True" 
                        EnableHeaderContextMenu="True" GridLines="None" EnableHeaderContextFilterMenu="True" 
                        AllowMultiRowEdit="false" AllowFilteringByColumn="True" OnPreRender="rg200_PreRender" 
                        OnItemCreated="rg200_ItemCreated" EnableViewState="False" OnUpdateCommand="rg200_UpdateCommand" 
                        AllowAutomaticDeletes="true" AllowAutomaticInserts="true"   
                        AllowAutomaticUpdates="true" oncancelcommand="rg200_CancelCommand"   
                        onpageindexchanged="rg200_PageIndexChanged">  
                        <HeaderStyle Height="20px" BackColor="#004000" Font-Size="8pt" Font-Bold="True" ForeColor="White" 
                            HorizontalAlign="Center" BorderColor="White" BorderWidth="1px" /> 
                        <ExportSettings IgnorePaging="true" ExportOnlyData="true">  
                            <Pdf AllowModify="false" AllowPrinting="true" PageBottomMargin="" PageFooterMargin="" 
                                PageHeaderMargin="" PageHeight="11in" PageLeftMargin="" PageRightMargin="" PageTopMargin="" 
                                PageWidth="14in" /> 
                        </ExportSettings> 
                        <MasterTableView GridLines="None" DataKeyNames="orderId" CommandItemDisplay="Top" 
                            EditMode="InPlace">  
                            <CommandItemSettings ShowExportToWordButton="true" ShowExportToExcelButton="true" 
                                ShowExportToCsvButton="true" ShowExportToPdfButton="true" ShowAddNewRecordButton="false" /> 
                            <Columns> 
                                <telerik:GridClientSelectColumn UniqueName="ClientSelectColumn" HeaderStyle-Width="3%" 
                                    ItemStyle-Width="3%">  
                                    <HeaderStyle Width="3%"></HeaderStyle> 
                                    <ItemStyle Width="3%"></ItemStyle> 
                                </telerik:GridClientSelectColumn> 
                                <telerik:GridBoundColumn UniqueName="sId" HeaderText="sId" DataField="sId" ReadOnly="true" 
                                    Visible="false">  
                                </telerik:GridBoundColumn> 
                                <telerik:GridBoundColumn UniqueName="orderId" HeaderText="orderId" Visible="false" 
                                    DataField="orderId">  
                                </telerik:GridBoundColumn> 
                                <telerik:GridBoundColumn UniqueName="Customer Name" HeaderText="Customer Name" DataField="Customer Name" 
                                    ReadOnly="true">  
                                </telerik:GridBoundColumn> 
                                <telerik:GridBoundColumn UniqueName="Market Name" HeaderText="Market Name" DataField="Market Name" 
                                    ReadOnly="true">  
                                </telerik:GridBoundColumn> 
                                <telerik:GridBoundColumn UniqueName="LOB" HeaderText="LOB" DataField="LOB" ReadOnly="true">  
                                </telerik:GridBoundColumn> 
                                <telerik:GridBoundColumn UniqueName="Headend Name" HeaderText="Headend Name" DataField="Headend Name" 
                                    ReadOnly="true">  
                                </telerik:GridBoundColumn> 
                                <telerik:GridBoundColumn UniqueName="Project Name" HeaderText="Project Name" DataField="Project Name" 
                                    ReadOnly="true">  
                                </telerik:GridBoundColumn> 
                                <telerik:GridBoundColumn UniqueName="Site Name" HeaderText="Site Name" DataField="Site Name" 
                                    ReadOnly="true">  
                                </telerik:GridBoundColumn> 
                                <telerik:GridBoundColumn UniqueName="Task Status" HeaderText="Task Status" DataField="Task Status" 
                                    ReadOnly="true">  
                                </telerik:GridBoundColumn> 
                                <%--<telerik:GridTemplateColumn UniqueName="Clarify Account Nbr" HeaderText="Clarify Account Nbr" 
                                    DataField="Clarify Account Nbr">  
                                    <ItemTemplate> 
                                        <asp:Label ID="lblClarifyAccountNbr" Text='<%# Eval("Clarify Account Nbr") %>' runat="server"></asp:Label> 
                                    </ItemTemplate> 
                                    <EditItemTemplate> 
                                        <asp:TextBox ID="txtClarifyAccountNbr" Text='<%# Eval("Clarify Account Nbr") %>' 
                                            runat="server"></asp:TextBox> 
                                    </EditItemTemplate> 
                                </telerik:GridTemplateColumn>--%> 
                                <telerik:GridBoundColumn UniqueName="Clarify Account Nbr" HeaderText="Clarify Account Nbr" 
                                    DataField="Clarify Account Nbr">  
                                </telerik:GridBoundColumn> 
                                <telerik:GridBoundColumn UniqueName="Site ID" HeaderText="Site ID" DataField="Site ID">  
                                </telerik:GridBoundColumn> 
                                <telerik:GridBoundColumn UniqueName="Quote ID" HeaderText="Quote ID" DataField="Quote ID">  
                                </telerik:GridBoundColumn> 
                                <telerik:GridCheckBoxColumn UniqueName="EDP Created?" HeaderText="EDP Created?" DataField="EDP Created?">  
                                </telerik:GridCheckBoxColumn> 
                                <telerik:GridEditCommandColumn UniqueName="EditCommandColumn" Visible="false">  
                                </telerik:GridEditCommandColumn> 
                            </Columns> 
                        </MasterTableView> 
                        <ClientSettings EnableRowHoverStyle="true" ReorderColumnsOnClient="false" AllowDragToGroup="false" 
                            AllowColumnsReorder="True">  
                            <Scrolling AllowScroll="true" EnableVirtualScrollPaging="false" UseStaticHeaders="true" /> 
                            <Selecting AllowRowSelect="True"></Selecting> 
                            <Resizing AllowRowResize="true" AllowColumnResize="True" EnableRealTimeResize="True" 
                                ResizeGridOnColumnResize="False"></Resizing> 
                            <ClientEvents OnRowContextMenu="RowContextMenu"></ClientEvents> 
                        </ClientSettings> 
                        <PagerStyle Mode="NextPrevAndNumeric" AlwaysVisible="true"></PagerStyle> 
                    </telerik:RadGrid> 
0
Accepted
Veli
Telerik team
answered on 07 Jul 2010, 08:05 AM
Hi Raj,

Note that removing the NeedDataSource event is not recommended! Particularly, when using advanced data operations like paging, sorting and data editing, it is required that RadGrid is databound using the NeedDataSource event. Consider using the NeedDataSource event only and remove the BindGrid method calls from Page_Load and other event handlers. You need to provide RadGrid's data inside the NeedDataSource event handler only. When you need to explicitly rebind the grid, simply call RadGrid.Rebind(). Note that RadGrid will automatically fire its NeedDataSource event for operations that require rebinding (e.g. Paging, Sorting, Fitlering, Update, Insert, Delete), so you do not need to explicitly rebind it in these cases. For more information, refer to the RadGrid Advanced DataBinding help topic.

The edit form stays open after update, because you have set AllowAutomaticUpdates/Inserts/Deletes to true. Note that these properties enable automatic data source operations and these work when binding to data source controls only (e.q. SqlDataSource, LinqDataSource, etc). Remove these properties to have the edit form close every time you click Update.

As for disabling the ViewState, note that RadGrid has certain limitations and does not provide its full set of functionality with disabled ViewState. Please refer to the RadGrid Optimizing ViewState Usage help article for more information on what is supported with disabled ViewState and what not.

Greetings,
Veli
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Raj
Top achievements
Rank 1
answered on 07 Jul 2010, 08:09 PM
Hi Veli,

Thanks for your help its working fine. I am able to update by grid using onneeddatasource. Thanks for your help.
Tags
Grid
Asked by
Raj
Top achievements
Rank 1
Answers by
Veli
Telerik team
Raj
Top achievements
Rank 1
Share this question
or