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
Register
Register | FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Display Modes
  #1 (permalink)  
Old June 28th, 2013, 04: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?

Code:
 
    <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>                                    
        <Columns>
<asp:TemplateField>
             <HeaderTemplate>
                Parts
                <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:DropDownList>
            </HeaderTemplate>
                 <EditItemTemplate>
                     <asp:Label ID="part_kit" runat="server" 
                         Text='<%# Eval("part_kit") %>' Width="30px"></asp:Label>
                 </EditItemTemplate>
                 <ItemTemplate>
                     <asp:Label ID="part_kit" runat="server"  ItemStyle-HorizontalAlign="Center"
                         Text='<%# Bind("part_kit") %>' Width="30px"></asp:Label>
                     &nbsp;
                 </ItemTemplate>
                <ItemStyle CssClass="gvItemCenter"  Width="30px"/>
            </asp:TemplateField>
    <asp:TemplateField>
             <HeaderTemplate>
                Stds
                <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:DropDownList>
            </HeaderTemplate>
                <EditItemTemplate>
                     <asp:Label ID="STD_Kit" runat="server" 
                         Text='<%# Eval("STD_Kit") %>' Width="30px"></asp:Label>
                 </EditItemTemplate>
                 <ItemTemplate>
                     <asp:Label ID="STD_Kit" runat="server"  ItemStyle-HorizontalAlign="Center"
                         Text='<%# Bind("STD_Kit") %>' Width="30px"></asp:Label>
                     &nbsp;
                </ItemTemplate>
                <ItemStyle CssClass="gvItemCenter" Width="30px" />
            </asp:TemplateField>
    <asp:TemplateField>


    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

            Else
                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
tks
 


Thread Tools
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 08:10 PM
Javascript functions from Gridview RowCommand Event Phil Critchley ASP.NET 4 General Discussion 21 May 3rd, 2011 11:55 PM
Glow the lable in From anukagni Access 15 October 17th, 2008 12:36 PM
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 07:41 AM



All times are GMT -4. The time now is 03:40 AM.


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