Results 1 to 6 of 6

Thread: wierd gridview behavior

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    wierd gridview behavior

    ok so this works on the default page no problem.

    but when I copy and paste the gridview control along with its events, or even create a new gridview control and recode - it doesnt work!!!

    firstly, if I set the AllowAutoGenerateColumns=false, it doesnt work - doesnt show any results but if i take out that line, it shows the results and shows the column names from a strongly typed datatable.

    Secondly, on the RowDataBound event, I have some code that does some formatting in the cells. On each cell it doesnt seem to get the header text but the headertext is there!

    any ideas what could be causing this strange behavior?

    edit: ok found out that the allowsorting generates a control inside that cell - a heading click link button. Thing is, how come this did not do it on the original page?
    in addition, when I place my own custom buttons/images in the headerrow and press the image to do a postback and sort the results - nothing happens. it does not postback to the server even though it has all the eventhandlers added to the control!

    but the original page has no problem like this
    Last edited by Techno; May 31st, 2007 at 04:51 AM.

    MVP 2007-2010 any chance of a regain?
    Professional Software Developer and Infrastructure Engineer.

  2. #2

    Thread Starter
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    Re: wierd gridview behavior

    the other thing is, eventually when the "sorting" images are placed/added into the headerrow of the gridview, when clicked on for some reason the entire gridview just hides itself! it doesnt even fire any event (even though ive told it/created the eventhandler for the image button).

    MVP 2007-2010 any chance of a regain?
    Professional Software Developer and Infrastructure Engineer.

  3. #3
    Banned timeshifter's Avatar
    Join Date
    Mar 2004
    Location
    at my desk
    Posts
    2,465

    Re: wierd gridview behavior

    The first thing I'd advise is to avoid trying to get the header info straight from the GridView. I've had nothing but issues with that. My solution was to create a data set equal to GridView.DataSource, then pick that apart for the needed info. It's really not too difficult.

    As for the odd behavior. What exactly is the default page doing, and what is the other page not doing that it's supposed to?

  4. #4

    Thread Starter
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    Re: wierd gridview behavior

    im afraid i need to add items into the headerrow for each column (sort buttons). I dont understand why it works PERFECTLY for the original page but not the new page when its a copy and paste job pretty much.

    the default page is doing nothing really. has a button to execute a report, which calls SQL, fills a datatable and binds it to the gridview. Same as what this new page is doing.

    just makes no sense to me.

    Ive noticed that when say we click on a button either in a datarow or a header on this new page in the gridview, that nothing happens but makes the gridview disappear!

    MVP 2007-2010 any chance of a regain?
    Professional Software Developer and Infrastructure Engineer.

  5. #5
    Banned timeshifter's Avatar
    Join Date
    Mar 2004
    Location
    at my desk
    Posts
    2,465

    Re: wierd gridview behavior

    Or... in the GridView statement, pull this little trick:
    <asp:GridView ID="myGV" runat="server" AllowSorting="True" ..... >

    And that will automatically take care of the sorting issue.

    Make sure the data is going through the right channels. If you copied the gridview without copying it's corresponding data source, then I can understand why it's disappearing.. it has no data to show. If it's programatic, make sure the object names are correct.

  6. #6

    Thread Starter
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    Re: wierd gridview behavior

    found out eventually the problem

    shouldve set the whole binding process after the if (!Page.IsPostBack) - that was the problem!

    i was doing it in that if statement in this new page, but shouldve been after that..... jeez.

    thanks anyway

    MVP 2007-2010 any chance of a regain?
    Professional Software Developer and Infrastructure Engineer.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width