imagebutton not responding
imagebutton not responding
imagebutton not responding
imagebutton not responding
imagebutton not responding
imagebutton not responding imagebutton not responding imagebutton not responding imagebutton not responding imagebutton not responding imagebutton not responding imagebutton not responding imagebutton not responding
imagebutton not responding imagebutton not responding
imagebutton not responding
Go Back  Xtreme Visual Basic Talk > > > imagebutton not responding


Reply
 
Thread Tools Display Modes
  #1  
Old 12-15-2011, 11:36 AM
calder calder is offline
Contributor
 
Join Date: Nov 2005
Posts: 483
Default imagebutton not responding


Hey guys,

Okay I've stared at this code for ages and I'm obviously missing something. I have a Gridview with an imagebutton in it. If I use a buttonfield it responds in the rowcommand no problem at all but for some reason the imagebutton doesn't.

ASP bit
HTML Code:
<asp:TemplateField>
                    <ItemTemplate>
                        <asp:ImageButton ID="btnBid" runat="server" CommandArgument='<%#EVAL("pro_id") %>' CommandName="place_bid" Visible="false" ImageUrl="~/pics/bid.png" />
                        <asp:ImageButton ID="btnBuy" runat="server" CommandArgument='<%#EVAL("pro_id") %>' CommandName="Add" Visible="false" ImageUrl="~/pics/buy.png" />
                    </ItemTemplate>
                 </asp:TemplateField>
Code behind bit (ignore the stupid code it's just to test if it's working)
Code:
Protected Sub GridView1_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles GridView1.RowCommand
        If e.CommandName = "Add" Then
            Me.Label12.Text = e.CommandArgument.ToString
else me.Label12.Text = "wth"
        End If
    End Sub

The visible bit is because it determines which button to show based on the database, this is the reason I went with the imagebutton because I couldn't figure out how to toggle visibility with the buttonfield. For the record changing visibility in the code itself has no impact on the result.

What the heck am I missing? >.<
__________________
I have learned more about VB from this forum in 3 months than I learned alone in 1 year. Share your knowledge and learn from others ;)
Reply With Quote
  #2  
Old 12-15-2011, 12:49 PM
calder calder is offline
Contributor
 
Join Date: Nov 2005
Posts: 483
Default

Solved.

For anyone wondering it's an issue with Viewstate of the content placeholders and binding the data to the gridview. Absolutely idiotic that one button works and the other doesn't in this instance but eh, at least it works now.

Set Viewstate to True for the contentplaceholder
Turn off databinding on postback for the Gridview.
problem solved.
__________________
I have learned more about VB from this forum in 3 months than I learned alone in 1 year. Share your knowledge and learn from others ;)
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
imagebutton not responding
imagebutton not responding
imagebutton not responding imagebutton not responding
imagebutton not responding
imagebutton not responding
imagebutton not responding imagebutton not responding imagebutton not responding imagebutton not responding imagebutton not responding imagebutton not responding imagebutton not responding
imagebutton not responding
imagebutton not responding
 
imagebutton not responding
imagebutton not responding
 
-->