Can't quite wrap my head around this one...
Given a datagrid, based on an underlying DataTable, that has two Button Columns and several bound columns:
<Columns>
<asp:ButtonColumn Text="Edit" ButtonType="PushButton" CommandName="Edit"></asp:ButtonColumn>
<asp:ButtonColumn Text="Disable" ButtonType="PushButton" CommandName="Disable"></asp:ButtonColumn>
<asp:BoundColumn DataField="AccountName" HeaderText="Account Name"></asp:BoundColumn>
<asp:BoundColumn DataField="AccountNumber" HeaderText="Account Number"></asp:BoundColumn>
</Columns>
Each account has a binary flag to denote if it is active. If the flag is not set, for that row, I would like to
1) Display the row in italics
2) Disable the 'Edit button in column 1
3) Change the label for the button in cloumn 2 from 'Disable' to 'Enable'
The first part is easy:
Private Sub dgAccounts_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles dgAccounts.ItemDataBound
If ((e.Item.ItemType = ListItemType.Item) Or (e.Item.ItemType = ListItemType.AlternatingItem)) Then
Dim Active As Integer = Convert.ToInt32(DataBinder.Eval(e.Item.DataItem, "Active")
If (Active = 0) Then
e.Item.Font.Italic = True
End If
End If
End Sub
I suspect that the answers to parts two and three are also handled within this function, but I cannot figure this out. Your help is greatly appreciated.
----
Gerry Roston
gerry@pairofdocs.net
Given a datagrid, based on an underlying DataTable, that has two Button Columns and several bound columns:
<Columns>
<asp:ButtonColumn Text="Edit" ButtonType="PushButton" CommandName="Edit"></asp:ButtonColumn>
<asp:ButtonColumn Text="Disable" ButtonType="PushButton" CommandName="Disable"></asp:ButtonColumn>
<asp:BoundColumn DataField="AccountName" HeaderText="Account Name"></asp:BoundColumn>
<asp:BoundColumn DataField="AccountNumber" HeaderText="Account Number"></asp:BoundColumn>
</Columns>
Each account has a binary flag to denote if it is active. If the flag is not set, for that row, I would like to
1) Display the row in italics
2) Disable the 'Edit button in column 1
3) Change the label for the button in cloumn 2 from 'Disable' to 'Enable'
The first part is easy:
Private Sub dgAccounts_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles dgAccounts.ItemDataBound
If ((e.Item.ItemType = ListItemType.Item) Or (e.Item.ItemType = ListItemType.AlternatingItem)) Then
Dim Active As Integer = Convert.ToInt32(DataBinder.Eval(e.Item.DataItem, "Active")
If (Active = 0) Then
e.Item.Font.Italic = True
End If
End If
End Sub
I suspect that the answers to parts two and three are also handled within this function, but I cannot figure this out. Your help is greatly appreciated.
----
Gerry Roston
gerry@pairofdocs.net