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

[Solved] Grids Issue

5 Answers 299 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Valdy
Top achievements
Rank 1
Valdy asked on 01 May 2008, 01:15 PM
Hi there

I have a grids that 10 rows and 18 columns and 10 columns of them are setting like this so they are in edit mode.

protected void Page_PreRender(object sender, System.EventArgs e)  
        {  
            if (!this.IsPostBack)  
            {  
                for (int i = 0; i < this.radgrdTenderTariffTenderTariff.MasterTableView.Items.Count; i++)  
                {  
                    this.radgrdTenderTariffTenderTariff.MasterTableView.Items[i].Edit = true;  
                }  
                this.radgrdTenderTariffTenderTariff.MasterTableView.Rebind();  
            }  
        } 

Now ... i have a button outside this grid and just want to save the value of each edited column by doing this:



protected void bttnSave_Click(object sender, EventArgs e)  
        {  
            foreach (GridEditableItem editedItem in radgrdTenderTariffTenderTariff.EditItems)  
            {  
                //string test = item.OwnerTableView.DataKeyValues[item.ItemIndex]["SiteCode"].ToString();  
                //GridEditableItem itemToEdit = (item.OwnerTableView.EditMode == GridEditMode.InPlace) ?  
                //        (GridEditableItem)item : (GridEditableItem)item.EditFormItem;  
                string rate8 = editedItem["Rate8"].Text;  
 
 
            }  
        } 

But I don't get any values of edited columns.  Any ideas? Unless is there any other methods to set the editable mode.

Thanks




5 Answers, 1 is accepted

Sort by
0
Yavor
Telerik team
answered on 01 May 2008, 01:25 PM
Hello Alison,

You can get any of the edit items in the control, as shown in the code snippet below:

.cs
 protected void Button1_Click(object sender, EventArgs e)  
    {  
        GridEditFormItem editForm = (GridEditFormItem) RadGrid1.MasterTableView.GetItems(GridItemType.EditFormItem)[0];  
    } 



Sincerely yours,
Yavor
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Valdy
Top achievements
Rank 1
answered on 01 May 2008, 01:39 PM
Actually .. I am using InPlace edit mode.

I did try that you suggest and it throws an error for IndexOutOfRangeException

GridEditFormItem

editForm = (GridEditFormItem)radgrdTenderTariffTenderTariff.MasterTableView.GetItems(GridItemType.EditFormItem)[0];

Any ideas?

0
Yavor
Telerik team
answered on 01 May 2008, 02:06 PM
Hi Alison,

In this case (inline edit mode) the items will not be editform items, but rather dataitems. you can get the items/controls in the edit item, as shown in the code below:

.cs
 protected void Button1_Click(object sender, EventArgs e)  
    {  
        GridDataItem dataItem = RadGrid1.MasterTableView.Items[0];  
        TextBox editedTextBox = (TextBox)dataItem["CompanyName"].Controls[0];  
        Response.Write(editedTextBox.Text);  
    } 

I hope this helps.

Regards,
Yavor
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Valdy
Top achievements
Rank 1
answered on 01 May 2008, 02:18 PM
Also, I forget to mentioned that I allow the 

AllowMultiRowEdit

="true"

So how do I access each inividual rows and columns as you said previously.

Cause that one works only first rows.

Thanks

0
Yavor
Telerik team
answered on 02 May 2008, 10:08 AM
Hi Alison,

You can get any item from the control, by replacing the 0 in the expression below:
RadGrid1.MasterTableView.Items[0]; 

with the number of the item of interest. Also, you can check if the item is in edit mode, and simply iterate through all the edited items.

Sincerely yours,
Yavor
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Grid
Asked by
Valdy
Top achievements
Rank 1
Answers by
Yavor
Telerik team
Valdy
Top achievements
Rank 1
Share this question
or