如何在单击ASP Datagrid时选择行?

时间:2015-04-14 12:14:48

标签: javascript c# asp.net datagrid

每当我点击相应行上的任何单元格时。我需要能够在我的asp中选择一行:Datagrid

<asp:DataGrid ID="dgDocument" SelectionMode="Single" runat="server" Localizable="True" Width="100%" UpdateAfterCallBack="False"   AutoGenerateColumns="False" CssClass="Grid"  OnSelectedIndexChanged="dgproposal_SelectedIndexChanged">
<AlternatingItemStyle CssClass="GridAlternativeItem"></AlternatingItemStyle>
<ItemStyle CssClass="GridItem"></ItemStyle>
<Columns>
<asp:BoundColumn Visible="False" DataField="DOCUMENT_NUMBER" HeaderText="Document Number">
</asp:BoundColumn>
<asp:TemplateColumn HeaderText="Document Title">
<ItemTemplate>
<asp:Label runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.DOCUMENT_NAME") %>' ID="Label3" NAME="Label3">
</asp:Label>
</ItemTemplate>
</asp:TemplateColumn>
...

1 个答案:

答案 0 :(得分:0)

使用SelectedItemStyle定义所选记录。

 <SelectedItemStyle BackColor="Yellow">
         </SelectedItemStyle>

https://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.datagrid.selecteditemstyle(v=vs.110).aspx