Jump to content
Xtreme .Net Talk

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


Recommended Posts

Posted

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

Posted (edited)

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. ;)

Edited by JRichmond
Posted

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 :-\

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...