SA Developer .NET

Welcome to SA Developer .NET Sign in | Join | Help
in Search

The grid nightmare

Last post 07-24-2008, 15:55 by EricTruter. 5 replies.
Sort Posts: Previous Next
  •  07-24-2008, 12:37 13645

    The grid nightmare

    Hi guys,

    I need some help with a grid view (which I absolutely h.a.t.e)...

    I have a TemplateField with a normal HTML Anchor <a> link. Within the OnRowDataBound event, I look for a specific status and then give the anchor a link to which it should link for a specific item. This part works fine, but when I try to active the link, I get an invalid postback or callback error, which is absolutely killing me.

    I've done some UGoogling but nothing concrete is returned.

    How can I dynamically add the anchor's URL reference without being returned this invalid postback or callback error?

    Regards,

    Eric

    'Not everything is binary, if you look closer you might find some hexadecimal in there somewhere'
  •  07-24-2008, 13:30 13646 in reply to 13645

    Re: The grid nightmare

    A very wild guess is it's something to do with ViewState verification, or whatever it's called.

    Unscrambling Eggs: Decompiling ASP.NET
  •  07-24-2008, 13:32 13647 in reply to 13646

    Re: The grid nightmare

    Why not try changing the HTML tag to a LinkButton? That might work...

    "I would love to change the world, but they won't give me the source code"
    SMS your TO DO list to your email
  •  07-24-2008, 14:02 13651 in reply to 13647

    Re: The grid nightmare

    The problem is I don't need an actual link, I need a hyperlinked image which pops up a new window when clicked on. The ImageButton object does not support targeted window popups, and the hyperlink does not support images.

    That leaves me with a templated field that contains an anchor wrapped around an image all standard HTML controls. The f-up comes in when the link is clicked on, it causes a full postback. Because of this, it regenerated the "hyperlink" before it actually fires off it's previous state, damn I hate gridviews. The scenario seems pretty simple to resolve, add the "EnableEventValidation" page directive and make sure that the databinding, which I failed to mention is from a ObjectDataSource object I build up dynamically during runtime, is only executed if there is no postback on the page, but this does not work for this particular problem.

    What I can probably do is transform the presentation of the linkbutton to display an image instead of text using CSS which might work.


    'Not everything is binary, if you look closer you might find some hexadecimal in there somewhere'
  •  07-24-2008, 15:37 13656 in reply to 13651

    Re: The grid nightmare

    Try adding javascript to the databinding for the OnClientclick property of the ImageButton and you can specify what page or image to open in the binding e.g.:

    "J a v a s c r i p t:window.open('SomePage.aspx?PropertyID='" + eval("PropertyId") + "'','','height=450,width=650,left=100,top=100,scrollbars=yes,resizable=yes')"

    (Take the spaces out of J a v a s c r i p t in the above line).  

    There's an example at: http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.linkbutton.onclientclick(VS.80).aspx for a linkbutton but it also works with an imagebutton.

  •  07-24-2008, 15:55 13657 in reply to 13656

    Re: The grid nightmare

    ROTFL ....

    Actually this turned out to be a n00b problem, not with the gridview but with the actual developer, which turned out to be I bwahahaha

    I had an ImageButton within an anchor link, when the image got clicked on, it fired off both client and server-side event validatation, causing issues, such as the invalid postback or callback.

    Thanx for the response guys

    Eric

    'Not everything is binary, if you look closer you might find some hexadecimal in there somewhere'
View as RSS news feed in XML
Powered by Community Server (Commercial Edition), by Telligent Systems