Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > Dynamically Adding Bound Columns Won't Sort

Reply
Thread Tools

Dynamically Adding Bound Columns Won't Sort

 
 
Mark
Guest
Posts: n/a
 
      11-24-2003
All-

I'm basically creating a user control which contains a datagrid that will be
used throughout our application by all pages.
My user control contains a datagrid control and I expose methods to add a
bound column to the grid.
So when they call this function and pass in the field name and title, I
dynamically add this new bound column to the
grid. It works when loaded for the first time and the paging works fine
also.
The only problem is that the Sort event doesn't fire. The bound columns are
being recreated when the page reloads,
so the grid object has them. I don't get it.


Any help would be great. Thanks


 
Reply With Quote
 
 
 
 
Mark
Guest
Posts: n/a
 
      11-24-2003
FYI:

When I binded the data back to the grid on load, the event fired. Doesn't
make sense though, because when you add static columns
to the grid in Html, you don't have to do that. What this means is that if
you create the columns dynamically in code, you have to rebind the grid in
order to get the sort event, then figure out how to sort your data, and then
rebind once again. Two binds in one postback.

Either I'm missing something, or this is bad design on MS's part.



"Mark" <> wrote in message
news:...
> All-
>
> I'm basically creating a user control which contains a datagrid that will

be
> used throughout our application by all pages.
> My user control contains a datagrid control and I expose methods to add a
> bound column to the grid.
> So when they call this function and pass in the field name and title, I
> dynamically add this new bound column to the
> grid. It works when loaded for the first time and the paging works fine
> also.
> The only problem is that the Sort event doesn't fire. The bound columns

are
> being recreated when the page reloads,
> so the grid object has them. I don't get it.
>
>
> Any help would be great. Thanks
>
>



 
Reply With Quote
 
 
 
 
Jos
Guest
Posts: n/a
 
      11-26-2003
"Mark" <> wrote in message
news:...
> FYI:
>
> When I binded the data back to the grid on load, the event fired. Doesn't
> make sense though, because when you add static columns
> to the grid in Html, you don't have to do that. What this means is that

if
> you create the columns dynamically in code, you have to rebind the grid in
> order to get the sort event, then figure out how to sort your data, and

then
> rebind once again. Two binds in one postback.
>
> Either I'm missing something, or this is bad design on MS's part.


This is correct. In order to get postback from controls that are created
dynamically, you need to recreate them at postback.
Then you can handle the postback event and rebuild your page once again.

I wouldn't say it's bad design, because it's not easy to handle events from
controls that don't exist anymore.

--

Jos


 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
template columns and bound columns in gridview Vinki ASP .Net Web Controls 2 04-25-2007 04:22 PM
Getting data out of dynamically bound columns et ASP .Net Datagrid Control 0 05-14-2006 05:52 PM
Datagrid, adding bound columns. =?Utf-8?B?Sm9u?= ASP .Net 0 02-15-2006 09:22 AM
Dynamically data-bound columns versus asp:ButtonColumn slapdash ASP .Net Datagrid Control 0 11-02-2005 10:06 PM
Access to dynamically bound columns Bman ASP .Net Web Controls 1 10-10-2005 08:07 PM



Advertisments