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

[Solved] Edit Columns in Dynamically generated Grid

2 Answers 94 Views
Grid
This is a migrated thread and some comments may be shown as answers.
MKDurga Durga
Top achievements
Rank 1
MKDurga Durga asked on 22 Oct 2009, 05:16 AM
Hello All,

    My requirement is as follows. i need to edit a dynamically generated grid ( in which in which i cannot write a editcolumn template) , because i cant define how many columns will be coming. Functionality is as follows, i have Employee leave data,  in grid I need to show Empid, DOJ, Name, Leave Type1, Leave Type2, Leave Type3......... as defined in masters. When i load the grid i get all emp details and leave types as columns names, here i need to enter values in each type for each employee. When i bring the grid into edit mode I should not be able to edit  first three columns and all others should be in edit mode.

Hope I am clear. Can this be done.

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 22 Oct 2009, 10:18 AM
Hello MKDurga,

You can set the ReadOnly property for the first three columns to avoid editing for these columns as shown below:
c#:
protected void gridLearningList_PreRender(object sender, EventArgs e) 
    { 
        // excluding the first two columns, i.e., GridExpandColumn and GridRowIndicatorColumn 
        for (int i = 2; i < 5; i++)  
        {             
            ((GridBoundColumn)gridLearningList.MasterTableView.RenderColumns[i]).ReadOnly = true
        } 
    } 

Thanks
Princy.
0
MKDurga Durga
Top achievements
Rank 1
answered on 23 Oct 2009, 11:20 AM
Thanks Princy,

            Thanks for update. I could solve this issue, the other way. I binded grid  statically from database and for leave types i binded textboxes for input values. Now my problem is when iam giving values in textboxes, and changing page no, the previous page  values are getting cleared. How should i handle this. How can i retain the the values in previous pages , while moving pages.

Hope Iam clear,

Thanks
Durga
Tags
Grid
Asked by
MKDurga Durga
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
MKDurga Durga
Top achievements
Rank 1
Share this question
or