【问题标题】:How to Select Row in ASP Datagrid on clicking it?单击它时如何在 ASP Datagrid 中选择行?
【发布时间】:2015-06-20 01:03:45
【问题描述】:

每当我点击相应行上的任何单元格时。我需要能够在我的 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>
...

【问题讨论】:

  • 我需要它来为 onlick 工作。

标签: javascript c# asp.net datagrid


【解决方案1】:

使用 SelectedItemStyle 定义选中的记录。

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-04-19
    • 2022-06-14
    • 2012-01-02
    • 2011-12-10
    • 2015-11-22
    • 2011-09-21
    • 1970-01-01
    相关资源
    最近更新 更多