Hi,
I noticed you are overriding the OnItemCommand with:
OnItemCommand=" NurseAssig_Item Command"
you could use the PrivateDutyAssi gDG_ItemCommand that will be created with
studio. I truiedturning view state off and loading the grid on post back and
i still get a highlight. Here is a simple example that worked for me:
<form id="Form1" method="post" runat="server">
<asp:DataGrid id=dgAuthors style="Z-INDEX: 101; LEFT: 216px; POSITION:
absolute; TOP: 128px" runat="server" DataSource="<%# DsAuthors1 %>"
DataKeyField="a u_id" DataMember="aut hors" AutoGenerateCol umns="False"
EnableViewState ="False">
<SelectedItemSt yle BackColor="#CCC C99"></SelectedItemSty le>
<AlternatingIte mStyle BackColor="Silv er"></AlternatingItem Style>
<Columns>
<asp:ButtonColu mn Text="hi Lite" HeaderText="hi lite"
CommandName="Se lect"></asp:ButtonColum n>
<asp:BoundColum n DataField="au_i d" SortExpression= "au_id"
ReadOnly="True" HeaderText="au_ id"></asp:BoundColumn >
<asp:BoundColum n DataField="au_l name" SortExpression= "au_lname"
HeaderText="au_ lname"></asp:BoundColumn >
<asp:BoundColum n DataField="au_f name" SortExpression= "au_fname"
HeaderText="au_ fname"></asp:BoundColumn >
<asp:BoundColum n DataField="au_f name" SortExpression= "au_fname"
HeaderText="au_ fname"></asp:BoundColumn >
</Columns>
</asp:DataGrid>
</form>
1. I created a sqldataadapter off ofthe authors table on northwinds
2. added a dataset called dsauthors and an instance of it (dsAuthors1)
3. i filled the dataset on load.
this is the only code i added to get this running:
If Not IsPostBack Then
SqlDataAdapter1 .Fill(DsAuthors 1)
dgAuthors.DataB ind()
End If
I can give you the full example if you like.
I had a lot of frustration with vs.net so i understand it is not as
intuitive as everyone says. "Emperror's new cloths"! however, it does work if
you work withit.
I hope this helps
please let me know!!!
kes
"LU" wrote:
Here is the top portion of one of the datagrids
<asp:DataGrid id="PrivateDuty AssigDG" Runat="Server"
AutoGenerateCol umns="False" OnItemCommand=" NurseAssig_Item Command"
CellSpacing="1" width="100%" GridLines="None " Cellpadding="3"
HeaderStyle-BackColor="#99C CCC"
AlternatingItem Style-BackColor="#e3f 2f2" ItemStyle-BackColor="#DED FDE"
DataKeyField="P NID">
<SelectedItemSt yle BackColor="Gray "></SelectedItemSty le>
<EditItemStyl e Font-Names="arial;ve rdana"></EditItemStyle>
<AlternatingIte mStyle Font-Size="11px" Font-Names="Arial;Ve rdana"
BackColor="#E3F 2F2"></AlternatingItem Style>
<ItemStyle Font-Size="11px" Font-Names="arial;ve rdana"
BackColor="Whit e"></ItemStyle>
<HeaderStyle Font-Size="11px" Font-Names="arial;" Font-Bold="True"
ForeColor="Blac k" BackColor="#99C CCC"></HeaderStyle>
<Columns>
<asp:BoundColum n DataField="URPN AID" ReadOnly="True"
HeaderText="Ass ignmentID"></asp:BoundColumn >
<asp:BoundColum n DataField="PNID " ReadOnly="True"
HeaderText="Nur sesSysID"></asp:BoundColumn >
<asp:TemplateCo lumn>
<HeaderTemplate >
"Kurt Schroeder" wrote:
last post may not have been sent:
<SelectedItemSt yle BackColor="Gree n"></SelectedItemSty le> will work
"LU" wrote:
A)I build a datagrid based on a calendar date selection.
B)When user clicks a button column on the datagrid I want to highlight this
row. I use the code below to highlight the row.
***** CODE TO HIGHLIGHT ROW
Sub Datagrid_ItemCo mmand(ByVal s As Object, ByVal e As
DataGridCommand EventArgs)
If e.CommandName = "ViewUnitReques t" Then
e.Item.BackColo r = System.Drawing. Color.LightGray
end if
End Sub
*****
C)This works and the row clicked is highlighted.
D)Problem is if user clicks a different row, the old row stays highlighted
and the new row is highlighted.
E)How do I make sure the old row is back to normal color?
F)Do I need to rebind the datagrid before i change the color?
Thank you