i Updating a Row of Data w/ Templated Column in data grid and i need to "lock" some of datagrid cells,depend of some events(if ...), mean make some of the cell of row read-only in some moments(or may be make entire column read-only also help).
Hi, You can do this by finding that particular control in the edititemtemplate. I am giving a code snippet below for your reference.
Private Sub DataGrid1_EditCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DataGrid1.EditCommand
DataGrid1.EditItemIndex = e.Item.ItemIndex
BindGrid(DataGrid1)
CType(DataGrid1.Items(e.Item.ItemIndex).FindControl("txtTest1"), TextBox).ReadOnly = True
End Sub
Here txtTest1 is the name of the control which I want to lock and Bindgrid is a function where I bind the grid. Hope this
will resolve your problem. Thanks, Subha
mitkomk
Member
129 Points
36 Posts
How "lock" datagrid cells,depend of events(make read-only),in updating mode
Dec 28, 2004 06:53 AM|LINK
munas
Member
405 Points
81 Posts
Re: How "lock" datagrid cells,depend of events(make read-only),in updating mode
Dec 30, 2004 09:45 AM|LINK
Private Sub DataGrid1_EditCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DataGrid1.EditCommand DataGrid1.EditItemIndex = e.Item.ItemIndex BindGrid(DataGrid1) CType(DataGrid1.Items(e.Item.ItemIndex).FindControl("txtTest1"), TextBox).ReadOnly = True End SubHere txtTest1 is the name of the control which I want to lock and Bindgrid is a function where I bind the grid. Hope this will resolve your problem. Thanks, Subhamitkomk
Member
129 Points
36 Posts
Re: How "lock" datagrid cells,depend of events(make read-only),in updating mode
Jan 14, 2005 09:47 AM|LINK
Zath
Star
8057 Points
1772 Posts
Re: How "lock" datagrid cells,depend of events(make read-only),in updating mode
Jan 14, 2005 01:02 PM|LINK