簡體   English   中英

單擊該如何在ASP Datagrid中選擇行?

[英]How to Select Row in ASP Datagrid on clicking it?

每當我單擊相應行上的任何單元格時,我都需要能夠在我的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>
...

使用SelectedItemStyle定義所選記錄。

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

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM