views:

211

answers:

1

I currently am using an ASP.Net gridview control and when a sortexpression is defined on the column, the column header is rendered as a linkbutton. I want to know if it is possible to convert that LinkButton to a Button control and preserve all the functionality. I cannot use TemplateColumns because I using DataControlField implementation to create columns and add them to the grid.

Thanks a lot.

A: 

I don't think it's possible.

Your best bet would be to use CSS to style it like a button. Obviously it won't look like a default UI button, but this site doesn't use default UI buttons.

Joel Barsotti
Thanks for the response. I need more than just the style. In fact, I would want to style my buttons as LinkButtons if I can even get it to that point. My problem is that I want to implement a multisort based on if a user uses ctrl key when clicking on the column header but Firefox tries to open the "javascript:__doPostBack('ctl00$ContentPla..." link (the sort postback) in a new window instead of recognizing that its a js method. So I was thinking that if I could either convert the LinkButtons to Buttons or somehow disable Firefox ctrl + click, I can implement this functionality.
Also, please see this question: http://stackoverflow.com/questions/2046339/how-can-i-prevent-firefox-from-opening-the-gridview-header-sort-postback-link-in
The other options would be to store each click to the last sort order and create the multi sort that way. That would work especially well if you could wrap the table in a ajaxpanel. Beyond that of course you could create another control on the page responsible for sorting the table.
Joel Barsotti
Thanks again for the response Joel. Unfortunately, what you suggested (to add the new sort to the existing sort) is the current behavior already and the users want to be able to toggle between a "single sort" and "multi sort" option easily by using Ctrl Click.The other option to create a custom control to do table sorting sounds interesting. I am thinking something like a popup where you can check the columns and the sort order and hit apply to set the sort. The only problem is that it might be too much work and time for what we have for this task.
shouldn't be that different.Same logic, just wiring it into a different event. I don't how you are wiring you data into the gridview, but if you first convert the data into a dataview sorting the data becomes trivial, so goto a dataview, sort from the new control then rebind to the gridview.
Joel Barsotti