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

Dynamically adding template columns in edit mode for bulk update

4 Answers 174 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Taeho Yoo
Top achievements
Rank 1
Taeho Yoo asked on 28 Jul 2008, 06:35 AM

Hi there,

Thanking you for very quick responses,

What I am trying to do is for a grid

1. add template columns to the grid
2. display the grid in edit mode
3. when click "save all", update all edited rows

What I did
for 1

GridTemplateColumn assResult = new GridTemplateColumn();  
this.RadGridGradingBatchEntry.MasterTableView.Columns.Add(assResult);  
assResult.DataField = "UniqueDateField";  
assResult.UniqueName = "UniqueDateField";  
assResult.SortExpression = "UniqueDateField";  
assResult.HeaderText = "UniqueDateField";  
assResult.SortExpression = "UniqueDateField";  
assResult.DataType = System.Type.GetType("System.Int32");  
assResult.Resizable = true;  
assResult.ItemStyle.Wrap = true;  
assResult.ItemStyle.Width = 15;  
assResult.ItemTemplate = new MyTemplate()  // Mytemplate returns implements Itemplate and I created this class according to one of forums I found here.  

for 2

protected void RadGridGradingBatchEntry_PreRender(object sender, System.EventArgs e)  
    {  
        foreach (GridDataItem item in RadGridGradingBatchEntry.Items)  
        {  
            item.Edit = true;  
            RadGridGradingBatchEntry.Rebind();  
        }  
    } 

for 3

protected override void RaisePostBackEvent(IPostBackEventHandler source, string eventArgument)  
    {  
        base.RaisePostBackEvent(source, eventArgument);  
        if (source is RadGrid)  
        {  
            string[] postBackEventArgumentData = eventArgument.Split(':');  
            switch (postBackEventArgumentData[0])  
            {  
                case "SaveAll":  
                    foreach (string l_EachItem in postBackEventArgumentData[1].Split(','))  
                    {  
                        if (!(l_EachItem == ""))  
                        {  
                            GridItem item = (GridItem)((Table)RadGridGradingBatchEntry.MasterTableView.Controls[0]).Rows[int.Parse(l_EachItem)];  
                            GridEditableItem editedItem = (GridEditableItem)item;  
                            Hashtable newnewValues = new Hashtable();  
                            item.OwnerTableView.ExtractValuesFromItem(newValues, editedItem);  
 
                        }  
                    }  
 
                    break;  
            }  
        }  
    } 

Now problem is that when I look up newValues, all dynamically created columns are not visible but only columns that have been specified as bound column are available to access.

Your help will be appreciated as always,

Toby 

4 Answers, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 28 Jul 2008, 12:38 PM
Hello Taeho Yoo,

If RadGrid template columns are created programmatically, this must be done in Page_Init, as described here:

RadGrid Programmatic Creation

Please modify your project and let us know if you still have problems.

Greetings,
Dimo
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Carlos
Top achievements
Rank 1
answered on 20 May 2011, 06:01 PM
Hi,
I am having the same issue, but I cannot turn off the viewState on the page since I am using it heavily. I am trying to follow the link RadGrid Programmatic Creation but it seems not to have that page anymore. Can you point me to the right direction?

Thanks,
Carlos
0
taeho
Top achievements
Rank 1
answered on 23 May 2011, 12:23 AM
Hi Carlos,

Sorry that I am not giving you the right answer you are looking for but we decided to scrap the bulk update function using .net
Simply not reliable enough not because of ASP.NET application itself but because of unreliable network and internet I suppose.
So instead we develop Microsoft excel application.

Cheers

Taeho
0
Sebastian
Telerik team
answered on 24 May 2011, 01:34 PM
Hi Carlos,

Here is the proper url to the programmatic creation topic of RadGrid for ASP.NET AJAX:
http://www.telerik.com/help/aspnet-ajax/grid-programmatic-creation.html

Greetings,
Sebastian
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Tags
Grid
Asked by
Taeho Yoo
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Carlos
Top achievements
Rank 1
taeho
Top achievements
Rank 1
Sebastian
Telerik team
Share this question
or