Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 3.5 > BOOK: ASP.NET 3.5 Website Programming Problem Design Solution
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
BOOK: ASP.NET 3.5 Website Programming Problem Design Solution
This is the forum to discuss the Wrox book ASP.NET 3.5 Website Programming Problem Design Solution by Chris Love; ISBN: 978-0-470-18758-6
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET 3.5 Website Programming Problem Design Solution section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 28th, 2013, 03:05 PM
Registered User
Points: 5, Level: 1
Points: 5, Level: 1 Points: 5, Level: 1 Points: 5, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jun 2013
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default RowCommand not firing after programatically changing a Lable to LinkButton

I have the code working to change a templatefield from a label to a linkbutton when the value in the label = "Y". The column is rendered as a link where the value is "Y" and as a Label when value is "N".
What do I need to do to get the 'RowCommand' to fire once I click on the linkbutton?

    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" AllowSorting="True" 
                    Font-Names="Calibri" Font-Size="11pt" EmptyDataText="Make Filter Selection" 
                    Border="3" ForeColor="#333333" Width="100%" 
         style="margin-top: 0px; margin-bottom: 0px; margin-right: 0px;" Height="39px" 
                    AllowPaging = "True" PageSize = "29"  
                    DataKeyNames="LastRefreshDate" OnPageIndexChanging = "OnPaging" 
         GridLines="None" CellSpacing="1" BackColor="Black"
        <HeaderStyle BackColor="#507CD1" BorderColor="Blue" Font-Bold="True" 
             CssClass="DataGridFixedHeader" ForeColor="White" ></HeaderStyle>                                    
                <asp:DropDownList ID="ddlParts" runat="server" OnSelectedIndexChanged = "ddlParts_SelectedIndexChanged" 
                    Width="45px" AutoPostBack = "true" AppendDataBoundItems = "true" Font-Size="10pt" Font-Names="Calibri" >
                <asp:ListItem Text = "ALL" Value = " " ></asp:ListItem>
                     <asp:Label ID="part_kit" runat="server" 
                         Text='<%# Eval("part_kit") %>' Width="30px"></asp:Label>
                     <asp:Label ID="part_kit" runat="server"  ItemStyle-HorizontalAlign="Center"
                         Text='<%# Bind("part_kit") %>' Width="30px"></asp:Label>
                <ItemStyle CssClass="gvItemCenter"  Width="30px"/>
                <asp:DropDownList ID="ddlStds" runat="server" OnSelectedIndexChanged = "ddlStds_SelectedIndexChanged" 
                    Width="45px" AutoPostBack = "true" AppendDataBoundItems = "true" Font-Size="10pt" Font-Names="Calibri" >
                <asp:ListItem Text = "ALL" Value = " " ></asp:ListItem>
                     <asp:Label ID="STD_Kit" runat="server" 
                         Text='<%# Eval("STD_Kit") %>' Width="30px"></asp:Label>
                     <asp:Label ID="STD_Kit" runat="server"  ItemStyle-HorizontalAlign="Center"
                         Text='<%# Bind("STD_Kit") %>' Width="30px"></asp:Label>
                <ItemStyle CssClass="gvItemCenter" Width="30px" />

    Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound
        Dim clientID = ViewState("clientID")
        Dim companyCd As String = ViewState("CompanyCD")
        Dim bemsid = ViewState("bemsid")
        Dim currentRowIndex As Integer = e.Row.RowIndex
        Dim lbPartKit As New LinkButton()
        If currentRowIndex > 0 Then
            If currentRowIndex Mod 2 Then
                GridView1.Rows(currentRowIndex - 1).BackColor = Drawing.Color.LightBlue

                GridView1.Rows(currentRowIndex - 1).BackColor = Drawing.Color.Cornsilk
            End If
            _go.RowIndex = 1
            Dim key As String = GridView1.DataKeys(_go.RowIndex).Value.ToString()
            LastRun.Text = GridView1.DataKeys(_go.RowIndex).Value.ToString()
        End If
        If currentRowIndex > 0 Then
            Call GridView_SetLinkButtons(currentRowIndex)
        End If
        'End If
    End Sub

    Private Sub GridView_SetLinkButtons(currentRowIndex As Integer)
        Dim strPart_Kit As String
        Dim strSTDKit As String
        Dim SOIString As String
        Dim lbPartKit As New LinkButton()
        Dim lbSTDKit As New LinkButton()
        strPart_Kit = Trim(CType(GridView1.Rows(currentRowIndex - 1).FindControl("part_kit"), System.Web.UI.WebControls.Label).Text)
        strSTDKit = Trim(CType(GridView1.Rows(currentRowIndex - 1).FindControl("STD_Kit"), System.Web.UI.WebControls.Label).Text)
        SOIString = Trim(CType(GridView1.Rows(currentRowIndex - 1).FindControl("SOI_Number"), System.Web.UI.WebControls.Label).Text)

        If strPart_Kit = "Y" Then
            GridView1.Rows(currentRowIndex - 1).FindControl("part_kit").Visible = False
            lbPartKit.CommandName = "PartKit"
            lbPartKit.Text = strPart_Kit
            lbPartKit.CausesValidation = False
            lbPartKit.CommandArgument = (currentRowIndex - 1)
            lbPartKit.ForeColor = System.Drawing.ColorTranslator.FromHtml("#DC143C")  'Crimson'
            AddHandler lbPartKit.Command, AddressOf GridView1_RowCommand
            GridView1.Rows(currentRowIndex - 1).FindControl("part_kit").Controls.Add(lbPartKit)
            GridView1.Rows(currentRowIndex - 1).FindControl("part_kit").Visible = True
        End If
        If strSTDKit = "Y" Then
            GridView1.Rows(currentRowIndex - 1).FindControl("STD_Kit").Visible = False
            lbSTDKit.CommandName = "STDKit"
            lbSTDKit.Text = strSTDKit
            lbSTDKit.CausesValidation = False
            AddHandler lbSTDKit.Command, AddressOf GridView1_RowCommand
            GridView1.Rows(currentRowIndex - 1).FindControl("STD_Kit").Controls.Add(lbSTDKit)
            GridView1.Rows(currentRowIndex - 1).FindControl("STD_Kit").Visible = True
        End If
    End Sub

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't find control in GridView RowCommand rsearing ASP.NET 2.0 Professional 8 September 10th, 2011 07:10 PM
Javascript functions from Gridview RowCommand Event Phil Critchley ASP.NET 4 General Discussion 21 May 3rd, 2011 10:55 PM
Glow the lable in From anukagni Access 15 October 17th, 2008 11:36 AM
Issue of changing IPAddress programatically in win sraja C# 2005 1 March 6th, 2008 05:55 AM
multiline lable kripa ostwal Visual Basic 2005 Basics 1 April 6th, 2007 06:41 AM

All times are GMT -4. The time now is 10:24 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.