How to diable edit mode in the datagrid

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a datagrid that allows users to eidt/update detail records. The grid
shows detail records for a master record. Once the status of the master
record changes to "closed", I need to ensure that the users can't update the
detail records. The easiest way to do this may be to disable the edit button
on the detail grid.

How can I dynamically disable the edit mode for the entire datagrid based on
status of the master record or is there a better alternative?

Thank you
 
One way to do it, would be on the ItemDataBound event, where you could
disable the edit button as you said.

Not sure about doing it for a whole grid at once though.
 
I found this solution and it works pretty well..just thought I'd pass it along

<asp:DataGrid id="DataGrid1" runat="server">
<Columns>
<asp:TemplateColumn HeaderText ="Product Information" >
<ItemTemplate >
<asp:Button CommandName="Status" Text ="Status" Runat =server
Enabled
=<%#CheckStatus(Convert.ToBoolean(DataBinder.Eval(Container.DataItem,"AuditStatusID")))%> ID="Button1" >
</asp:Button>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>


VB.NET

Protected Function CheckStatus(ByVal StatusID As Boolean) As Boolean
If StatusID = 1 or StatusID = 2 Then
Return True
Else
Return False
End If
End Function
 
Back
Top