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

Read grid values in edit mode

1 Answer 70 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jouni
Top achievements
Rank 1
Jouni asked on 06 Jun 2010, 04:22 PM
Hello everybody!
This is how I have defined grid in aspx page:
<MasterTableView EditMode="InPlace" EnableViewState="False"
<RowIndicatorColumn> 
<HeaderStyle Width="20px"></HeaderStyle> 
</RowIndicatorColumn> 
 
<ExpandCollapseColumn> 
<HeaderStyle Width="20px"></HeaderStyle> 
</ExpandCollapseColumn> 
<Columns> 
    <telerik:GridBoundColumn DataField="PurchaseRecommendationLineID" UniqueName="PurchaseRecommendationLineID" Visible="false"/> 
    <telerik:GridTemplateColumn UniqueName="Product" DataField="Product"  HeaderText="Tuote" > 
        <EditItemTemplate> 
            <asp:TextBox ID="Text" runat="server"  Text='<%#Bind("Product") %> '/> 
        </EditItemTemplate> 
    </telerik:GridTemplateColumn> 
    <telerik:GridBoundColumn DataField="Unit" UniqueName="Unit" HeaderText="Yksikkö"/> 
        <telerik:GridNumericColumn DataField="Quantity"  UniqueName="Quantity" HeaderText="Määrä" HeaderStyle-Width="50px" NumericType="Number"/> 
     <telerik:GridBoundColumn DataField="Info" UniqueName="Info" HeaderText="Info"/> 
     
   
</Columns> 


I hope some can help me. I have all the grid items in Edit mode. Edit mode is done like this;
protected void ProposalGrid_PreRender(object sender, EventArgs e) 
        { 
            if (!IsPostBack || forceEditable) 
            { 
                forceEditable = false
 
                foreach (GridItem item in ProposalGrid.MasterTableView.Items) 
                { 
                    if (item is GridEditableItem) 
                    { 
                        GridEditableItem editableItem = item as GridDataItem; 
                        editableItem.Edit = true
                    } 
                } 
            } 
            ProposalGrid.Rebind(); 
        } 

I read Values from grid like this:
 private void CollectRowInformation(int headerid) 
        { 
         foreach (GridDataItem item in ProposalGrid.MasterTableView.Items)  
            { 
                RowObject ro = new RowObject(); 
              
                ro.Rowdata.Add("Unit", item["Unit"].Text); 
                ro.Rowdata.Add("Info", item["Info"].Text); 
                ro.Rowdata.Add("Quantity", item["Quantity"].Text); 
                ProsalService.Persist(ro); 
            } 
If I change some values in grid, and try to read it.I get always old value. I give you exsample.If Item orginal information is like this:
Unit:kg
Info:Plah
Quantity:4
And I change item information to
Unit:kg
Info:Plah2
Quantity:5555

If I put break point in CollectRowInformation and check values,It always show orginal values.How Can i read new values from grid.

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 07 Jun 2010, 09:27 AM
Hello Jouni,

The new values which the user entered before triggering the Update command can be fetched calling the ExtractValuesFromItem method. I saw a similar approach is used in a documentation to access the new values in the grid.

Also refer the following documentation:
Retrieving original values for edited item

I hope this information helps you,
Shinu.
Tags
Grid
Asked by
Jouni
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or