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

Problem with the grid when click on Add new record button

1 Answer 43 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Trinh Nguyen
Top achievements
Rank 1
Trinh Nguyen asked on 27 Apr 2010, 06:12 PM
I have the Telerik grid with custom rows to appear and disappear using:

    for (int i = 0; i < RadGridMain.MasterTableView.Items.Count; i++)
        {
            if (masterCL.Contains(int.Parse(RadGridMain.MasterTableView.DataKeyValues[i]["MasterChecklistID"].ToString())))
            {
                RadGridMain.MasterTableView.Items[i].Visible = false;
                RadGridMain.MasterTableView.Items[i].Enabled = false;
                RadGridMain0.MasterTableView.Items[i].Visible = true;
                flag = false;

            }
            else
            {
                RadGridMain.MasterTableView.Items[i].Visible = true;
                RadGridMain0.MasterTableView.Items[i].Visible = false;

            }

        }
Some of the columns in RadGridMain will invisble based on the method above. However, when I click on the Add new record to add new item. The invisible columns are visible again... how can I make it still invisible when clicking on Add new record button?

Thanks

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 28 Apr 2010, 08:09 AM
Hi,

You could try your code in PreRender event of the RadGrid after checking for the condition as shown below. PreRender is fired when the server control is about to render to its containing Page object. I hope this would help.

C#:
 
protected void RadGrid1_PreRender(object sender, EventArgs e) 
    if (condition) // Check for the condition here 
    { 
        for (int i = 0; i < RadGridMain.MasterTableView.Items.Count; i++) 
        { 
            if (masterCL.Contains(int.Parse(RadGridMain.MasterTableView.DataKeyValues[i]["MasterChecklistID"].ToString()))) 
            { 
                RadGridMain.MasterTableView.Items[i].Visible = false
                RadGridMain.MasterTableView.Items[i].Enabled = false
                RadGridMain0.MasterTableView.Items[i].Visible = true
                flag = false
            } 
            else 
            { 
                RadGridMain.MasterTableView.Items[i].Visible = true
                RadGridMain0.MasterTableView.Items[i].Visible = false
            } 
        } 
    } 

Regards,
Princy.
Tags
Grid
Asked by
Trinh Nguyen
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or