Dynamic change the 'Read Only' in datagrid(template column/Bound column)

calvin

Regular
Joined
Nov 6, 2003
Messages
71
I create few template column and bound column in datagrid. One of the template column contain the StudentMark. I want to know how to change that column to (Read only) or "Not" (Read only) when click the edit button. It is based on a dropdownlist to determine to read only or not. I think i must use the template column, since i need to do the validation to the StudentMark. (For example, If select value '1' in dropdownlist, the "StudentMark" is become 'Read only' and select '2' become vice versa. I was success to bind the datagrid and "StudentMark" become a textbox if I select '2'.

Anyone know how to do if i select '1' become a label and '2' become textbox :confused:

Thank you for any help and comments

Calvin
 
If I'm reading your question right, you could do it at least 2 different ways.

The first way is to use an EditItemTemplate column with the same controls as your ItemTemplate column, except with the StudentMark label replaced by a textbox. Then, when you postback from the DropDownList, you can set the DataGrid.EditItemIndex equal to the index of the DataGridItem that was clicked. To change it back, just change the EditItemIndex to -1.

The second way to do it is to have a Label AND a TextBox bound to the StudentMark field. Then, just make one or the other visible, depending on what the value of your dropdown list is.

I hope this helps. ;)
 
Last edited:
Just visible what i want

Hi,

I do two column, one is bound column and another is template column, i just visible the column what i want.


Thank you :-\
 
Back
Top