How to diable edit mode in the datagrid

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
 
G

Grant Merwitz

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.
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top