本文介绍了如何在LinkBut​​ton Click事件中选择GridView中的行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

< asp:GridView ID =grdtopicrunat =serverAutoGenerateColumns =falseCssClass =grdtopicBackColor =WhiteBorderColor =#999999BorderStyle =NoneBorderWidth =1pxCellPadding =3GridLines =VerticalOnRowCommand =grdtopic_RowCommandWidth =200pxOnSelectedIndexChanged =grdtopic_SelectedIndexChanged>

< alternatingrowstyle backcolor =#DCDCDC>

< footerstyle backcolor =#CCCCCCforecolor =Black>

< HeaderStyle BackColor =#000084Font-Bold =TrueForeColor =White/> ;

< pagerstyle backcolor =#999999forecolor =Blackhorizo​​ntalalign =Center>

< rowstyle backcolor =#EEEEEEforecolor =黑色>

< SelectedRowStyle BackColor =#008A8CFont-Bold =TrueForeColor =White/>

< sortedascendingcellstyle backcolor = #F1F1F1>

< sortedascendingheaderstyle backcolor =#0000A9>

< sorteddescendingcellstyle backcolor =#CAC9C9>

< sor teddescendingheaderstyle backcolor =#000065>



< columns>< asp:TemplateField HeaderText =ID>

< ; itemtemplate>

< asp:Label ID =lblIdrunat =serverText ='<%#Eval(TopicID)%>'>





< asp:TemplateField HeaderText =主题>

< itemtemplate>

< asp:LinkBut​​ton ID =lblTopicOnClick =Senddata_ClickCommandName =SelectCommandArgument ='<%#Eval(TopicID)%>'runat =server><%#Eval (主题名称)%>论文





如何在LinkBut​​ton Click事件或SelectedIndexChanged中选择GridView中的行?

请帮助先生。 ...

gridview selectedvalue在标签上显示.....

plz plz plz帮我...........

<asp:GridView ID="grdtopic" runat="server" AutoGenerateColumns="false" CssClass="grdtopic" BackColor="White" BorderColor="#999999" BorderStyle="None" BorderWidth="1px" CellPadding="3" GridLines="Vertical" OnRowCommand="grdtopic_RowCommand" Width="200px" OnSelectedIndexChanged="grdtopic_SelectedIndexChanged">
<alternatingrowstyle backcolor="#DCDCDC">
<footerstyle backcolor="#CCCCCC" forecolor="Black">
<HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" />
<pagerstyle backcolor="#999999" forecolor="Black" horizontalalign="Center">
<rowstyle backcolor="#EEEEEE" forecolor="Black">
<SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
<sortedascendingcellstyle backcolor="#F1F1F1">
<sortedascendingheaderstyle backcolor="#0000A9">
<sorteddescendingcellstyle backcolor="#CAC9C9">
<sorteddescendingheaderstyle backcolor="#000065">

<columns><asp:TemplateField HeaderText="ID">
<itemtemplate>
<asp:Label ID="lblId" runat="server" Text='<%# Eval("TopicID") %>'>


<asp:TemplateField HeaderText="Topic">
<itemtemplate>
<asp:LinkButton ID="lblTopic" OnClick="Senddata_Click" CommandName="Select" CommandArgument='<%# Eval("TopicID") %>' runat="server"><%# Eval("Topic Name") %> Paper


how to selected row in GridView on LinkButton Click event or SelectedIndexChanged?
plz help sir ....
that gridview selectedvalue display on label .....
plz plz plz help me...........

推荐答案

protected void grdtopic_RowCommand(object sender, GridViewCommandEventArgs e)
{
    if (e.CommandName == "Select")
    {
        LinkButton lnk = (LinkButton)e.CommandSource;
        string TopicID = lnk.CommandArgument;
        // do something
    }
}



这篇关于如何在LinkBut​​ton Click事件中选择GridView中的行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 10:06