Hello,
How to extract values from a GridEditFormItem from server side.
Here is my code.
ASP Markup :
Javascript :
C# code :
Attempt 1 :
Attempt 2 :
When I double click a row, the edit form pops below the row. But when I change the value and click update. It is not getting the new value. Instead its getting the old value. Please tell me how to get the new value.
Img1 : The new value I entered,
Img2 : Value I get from the code.
Really need some help on this.
How to extract values from a GridEditFormItem from server side.
Here is my code.
ASP Markup :
<telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True" CellSpacing="0" Skin="Transparent" GridLines="None" PageSize="10" AllowCustomPaging="True" AutoGenerateColumns="False" AllowSorting="True" OnItemDataBound="RadGrid1_ItemDataBound1" OnRowDrop="RadGrid1_OnRowDrop" AllowAutomaticUpdates="true" OnUpdateCommand="RadGrid1_UpdateCommand"> <PagerStyle Mode="NumericPages" /> <ClientSettings AllowRowsDragDrop="True"> <Selecting AllowRowSelect="true" /> <ClientEvents OnRowDropping="rowDropping" OnRowDblClick="RowDblClick" OnCommand="GridCommand" /> <Resizing AllowColumnResize="true" /> </ClientSettings> <MasterTableView AllowCustomPaging="False" AutoGenerateColumns="false" Caption="<%$Resources:BrandixResources, PWI_UnplannedItemsGrid_Title%>" Visible="True" DataKeyNames="ID, Effort" AllowNaturalSort="false" ClientDataKeyNames="Subject, Description, Effort"> <CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings> <SortExpressions> <telerik:GridSortExpression FieldName="DueDateTime" SortOrder="Ascending" /> </SortExpressions> <Columns> <telerik:GridBoundColumn UniqueName="ID" Visible="false" DataField="ID" ReadOnly="True"> </telerik:GridBoundColumn> <telerik:GridBoundColumn HeaderText="<%$Resources: Resources, Subject%>" DataField="Subject" UniqueName="Subject" ReadOnly="True"> </telerik:GridBoundColumn> <telerik:GridBoundColumn HeaderText="<%$Resources: Resources, DueDate%>" DataField="DueDateTime" DataFormatString="{0:dd/MM/yyyy} {0:hh}:{0:mm} {0:tt}" ReadOnly="True"> </telerik:GridBoundColumn> <telerik:GridBoundColumn HeaderText="<%$Resources: Resources, Effort%>" DataField="Effort"> </telerik:GridBoundColumn> <telerik:GridBoundColumn HeaderText="<%$Resources: Resources, UnplannedHours%>" DataField="UnplannedHours" ReadOnly="True"> </telerik:GridBoundColumn> <telerik:GridTemplateColumn HeaderText="<%$Resources: Resources, DraftPlan%>" UniqueName="DraftPlan" SortExpression="Status" ReadOnly="True"> <ItemTemplate> <asp:Label ID="lblGridStatus" runat="server" /> </ItemTemplate> </telerik:GridTemplateColumn> </Columns> <EditFormSettings> <EditColumn UniqueName="EditCommandColumn1"> </EditColumn> </EditFormSettings> </MasterTableView></telerik:RadGrid>Javascript :
var editedRow; function RowDblClick(sender, eventArgs) { editedRow = eventArgs.get_itemIndexHierarchical(); $find("<%= RadGrid1.ClientID %>").get_masterTableView().editItem(editedRow); } function GridCommand(sender, args) { if (args.get_commandName() != "Edit") { editedRow = null; } }C# code :
Attempt 1 :
protected void RadGrid1_UpdateCommand(object sender, GridCommandEventArgs e){ GridEditableItem item = e.Item as GridEditableItem; Dictionary<string, string> values = new Dictionary<string, string>(); item.ExtractValues(values); int id = Convert.ToInt32(item.GetDataKeyValue("ID"));}Attempt 2 :
protected void RadGrid1_UpdateCommand(object sender, GridCommandEventArgs e){ GridEditableItem item = e.Item as GridEditableItem; Dictionary<string, string> values = new Dictionary<string, string>(); e.Item.OwnerTableView.ExtractValuesFromItem(values, item);}When I double click a row, the edit form pops below the row. But when I change the value and click update. It is not getting the new value. Instead its getting the old value. Please tell me how to get the new value.
Img1 : The new value I entered,
Img2 : Value I get from the code.
Really need some help on this.