【问题标题】:getting text of particular control on rowcommand event在 rowcommand 事件上获取特定控件的文本
【发布时间】:2013-08-10 00:02:32
【问题描述】:

我想在 rowcommand 事件中获取链接按钮的文本。

我点击链接按钮,根据绑定到它的文本,我想做进一步的逻辑。

在 rowdatabound 上,我已根据数据库中的某些值将文本绑定到链接按钮。

现在在行命令上,我想检查该链接按钮的文本是否为“设为活动”,然后是进一步的逻辑,否则是进一步的逻辑。

我试着把它变成:

Protected Sub GrdMovieLst_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles GrdMovieLst.RowCommand
            If e.CommandName = "ActiveCheck" Then
                Dim gvRow As GridViewRow = GrdMovieLst.Rows(Convert.ToInt32(e.CommandArgument))
                if gvRow.FindControl("lbActiveCheck").Text Then /*here text property is not comming
            End If
End Sub

注意:C# 中的代码帮助也适合我。

gvRow.FindControl("lbActiveCheck").Text 没有给我链接按钮的文本。我想获取该特定行的链接按钮的文本。

请帮帮我。

链接按钮的 ASPX:

<ItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Edit"
                                                    Text="Edit"></asp:LinkButton>
 | <asp:LinkButton ID="lbActiveCheck" runat="server"   CommandName="ActiveCheck"></asp:LinkButton>
</ItemTemplate>

也欢迎 c# 方面的帮助。

【问题讨论】:

    标签: c# asp.net .net vb.net visual-studio-2008


    【解决方案1】:

    我用过这个:

     Dim row As GridViewRow = DirectCast(DirectCast(e.CommandSource, Control).NamingContainer, GridViewRow)
    
    CType(row.FindControl("lbActiveCheck"), LinkButton).Text = "Make As Inactive" 
    

    【讨论】:

      【解决方案2】:

      试试这个

      <ItemTemplate>
      <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Edit"
                                                          Text="Edit"></asp:LinkButton>
       | <asp:LinkButton ID="lbActiveCheck" runat="server" CommandArgument='<%# Container.DataItemIndex %>'  CommandName="ActiveCheck"></asp:LinkButton>
      </ItemTemplate>
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2011-09-24
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多