Avatar of Murray Brown
Murray Brown
Flag for United Kingdom of Great Britain and Northern Ireland

asked on 

ASP.net GridView button not working

Hi

I have the following ASP.net GridView button. On other pages it work but for some reason it isn't firing on this one page
I have included my markup and VB.net below

           <asp:GridView ID="GridView1" runat="server" AllowSorting="True" AutoGenerateColumns="False">
                    
                     
                     <Columns>
             
                 <asp:TemplateField HeaderText="?" ControlStyle-Forecolor ="Gray">
                    <ItemTemplate>
                        <asp:Button ID="ButtonQuestion" OnClientClick="showLoading();" runat="server" 
                        CommandName="btnQuestion" 
                        CommandArgument="<%# CType(Container, GridViewRow).RowIndex %>"
                        Text="?" />
                    </ItemTemplate>
                    <ControlStyle ForeColor="#468499" />
                </asp:TemplateField>

Open in new window


            ElseIf (e.CommandName = "btnQuestion") Then

                ' Retrieve the row index stored in the CommandArgument property.
                Dim index As Integer = Convert.ToInt32(e.CommandArgument)
                ' Retrieve the row that contains the button 
                ' from the Rows collection.
                Dim row As GridViewRow = GridView1.Rows(index)

                If IsPostBack Then

                    Dim lblItemID As Label = CType(row.FindControl("lblItemID"), Label)
                    Dim lblOrderQty As Label = CType(row.FindControl("lblOrderQty"), Label)
                    Dim lblDescription As Label = CType(row.FindControl("lblDescription"), Label)
                    Dim lblRandsPerTon As Label = CType(row.FindControl("lblUnitPrice"), Label)
                    Dim lblTotalPrice As Label = CType(row.FindControl("lblTotalPrice"), Label)
                    Dim lblCanOffer As Label = CType(row.FindControl("lblCanOffer"), Label)
                    Dim lblSellerUsername As Label = CType(row.FindControl("lblSellerUsername"), Label)

                    Dim oMessageHeader As String = "Offer Enquiry on Stock ID " & lblItemID.Text
                    oMessageHeader = oMessageHeader & " R/Ton " & lblRandsPerTon.Text
                    oMessageHeader = oMessageHeader & " Quantity " & lblOrderQty.Text
                    oMessageHeader = oMessageHeader & " Total Price " & lblTotalPrice.Text
                    Dim S As String
                    S = "Stock Detail:"
                    S = S & vbCrLf
                    S = S & vbCrLf & "Item ID: " & lblItemID.Text
                    S = S & vbCrLf & "Order Quantity: " & lblOrderQty.Text
                    S = S & vbCrLf & "Rands per Ton " & lblRandsPerTon.Text
                    S = S & vbCrLf & "Total Price " & lblTotalPrice.Text
                    'NOTE REPLACE BREAK IN LINE BELOW BECAUSE IT CAN"T BE EMAILED....
                    S = S & vbCrLf & "Description: " & Replace(lblDescription.Text, "<br/>", vbCrLf)

                    Session("oMessageStockDetail") = S

                    Session("oMessage_BuyerUsername") = oUsername
                    Session("oMessage_SellerUsername") = lblSellerUsername.Text

                    Session("oMessageFromEmail") = oUsername
                    Session("oMessageToEmail") = lblSellerUsername.Text

                    'REDIRECT TO MESSAGE WEB PAGE
                    Page.ClientScript.RegisterStartupScript(Me.[GetType](), "OpenWindow", "window.open('Message.aspx','_newtab');", True)

                    'Response.Redirect("Message.aspx") 'Same browser page

                End If

Open in new window

ASP.NETVisual Basic.NET

Avatar of undefined
Last Comment
Murray Brown

8/22/2022 - Mon