|
-
May 31st, 2007, 04:17 AM
#1
Thread Starter
PowerPoster
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.
-
May 31st, 2007, 06:34 AM
#2
Thread Starter
PowerPoster
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).
-
May 31st, 2007, 08:52 AM
#3
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?
-
May 31st, 2007, 09:23 AM
#4
Thread Starter
PowerPoster
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!
-
May 31st, 2007, 09:27 AM
#5
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.
-
May 31st, 2007, 10:08 AM
#6
Thread Starter
PowerPoster
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|