ISPrincess
Programmer
I need to disallow editing on a datagrid based on some value in one of the cells. Here is some background.
I have a datagrid, that has edit and delete buttons for each row. When the click the Edit, the column changes to Update / Cancel buttons. Everything so far is fine with that.
One of the cells in the table (named "InUse") has a value 0 or 1.
If that cells value is 1 then in the ItemDataBound event, I change the backcolor to red (thanks to posts in this forum): like so.
Now, my problem is that when the cell "InUse" is marked 1 and the row is colored Red - I do not want to allow any editing or deletion.
I am not sure how to do this.
It would be great if i could program it to be a client side message stating - cannot edit! or cannot delete! when they click and then do not open the row (edititemtemplate) for editing and do not fire the delete routines.
I have searched for posts on this and have gone thru my books but havent found anything.
Thanks!
PH
I was walking home one night and a guy hammering on a roof called me a paranoid little weirdo.
In morse code.
-Emo Phillips
I have a datagrid, that has edit and delete buttons for each row. When the click the Edit, the column changes to Update / Cancel buttons. Everything so far is fine with that.
One of the cells in the table (named "InUse") has a value 0 or 1.
If that cells value is 1 then in the ItemDataBound event, I change the backcolor to red (thanks to posts in this forum): like so.
Code:
Private Sub dgPrinters_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles dgPrinters.ItemDataBound
If e.Item.ItemType <> ListItemType.Header And e.Item.ItemType <> ListItemType.Footer Then
'If Printer is in use then color the row Red
'Note that the column to be evaluated must be a
' regular bound column and not an itemtemplate col.
If e.Item.Cells(4).Text = "1" Then
e.Item.BackColor = System.Drawing.Color.Red
End If
End If
End Sub
Now, my problem is that when the cell "InUse" is marked 1 and the row is colored Red - I do not want to allow any editing or deletion.
I am not sure how to do this.
It would be great if i could program it to be a client side message stating - cannot edit! or cannot delete! when they click and then do not open the row (edititemtemplate) for editing and do not fire the delete routines.
I have searched for posts on this and have gone thru my books but havent found anything.
Thanks!
PH
I was walking home one night and a guy hammering on a roof called me a paranoid little weirdo.
In morse code.
-Emo Phillips