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

RadGrid Updating Problem

1 Answer 60 Views
Grid
This is a migrated thread and some comments may be shown as answers.
I
Top achievements
Rank 1
I asked on 15 Jun 2011, 12:13 AM
Hi, I am using RadGrid control into my web form and editing within grid. But when click on update then i am getting old values which has been picked up from database but i need to get new values added into grid text box. Please have a look on code guid me how may i fix this.

<

 

radGrid:RadGrid ID="gdViewOrders" runat ="server" AutoGenerateColumns="false"  AllowMultiRowSelection="false" EnableAJAX="true" AllowMultiRowEdit="true" OnEditCommand="gdViewOrder_EditMode" OnUpdateCommand="gdViewOrder_UpdateMode">

 

 

<MasterTableView EditMode="InPlace" DataKeyNames="OrdID">

 

 

<Columns>

 

 

    <radGrid:GridEditCommandColumn UniqueName="EditCommandColumn"></radGrid:GridEditCommandColumn>

 

 

    <radGrid:GridBoundColumn HeaderText="Order ID" DataField="OrdID" ReadOnly="true"></radGrid:GridBoundColumn>

 

 

    <radGrid:GridBoundColumn HeaderText="Name" DataField="CustName" UniqueName="Name"></radGrid:GridBoundColumn>

 

 

</Columns>

 

 

 

</MasterTableView>

 

 

</radGrid:RadGrid>

 


Code:

protected

 

void gdViewOrder_UpdateMode(object sender, Telerik.WebControls.GridCommandEventArgs e)

 

 

{

 

 

        GridEditableItem editedItem = (GridEditableItem)e.Item;

 

 

 

        int id = Convert.ToInt32(editedItem.GetDataKeyValue("OrdID"));

 

 

 

        string objName = (editedItem["Name"].Controls[0] as TextBox).Text;

 

 

        bool response = objOrders.UpdateOrder(id, objName, objAddress.Text, objSeller.Text, Convert.ToInt32(objStatus.Text));

 

 

 

        lblMessage.Text = "Order has not been updated successfully.";

 

 

}


Thanks

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 15 Jun 2011, 08:50 AM
Hello,

I was unable to recreate the issue with the given information. Please make sure that you haven't call any databind method before updating. It will cause the TextBox value to be replace with the database value.

Check out the following help article for more on the CRUD operations.
Insert/update/delete at database level with queries.

Thanks,
Shinu.
Tags
Grid
Asked by
I
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or