473,785 Members | 2,801 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dynamic columns not sorting in DataGrid

I am creating a data grid's columns on the fly in my web page. The Bind
operation works just fine, and data is displayed correctly when I change the
layout of the grid (add/remove columns).

I change the data grid by first removing all of the columns then adding each
of the columns that I need for a particular report.

My data grid has a "sort" handler:

this.Report.Sor tCommand += new
System.Web.UI.W ebControls.Data GridSortCommand EventHandler(th is.Report_SortC ommand);

which is set in the InitializeCompo nent() method of my WebForm. I setup the
column data model in my BindData() method of the form, which occurs AFTER the
initialization (of course).

This is my Report_SortComm and:

private void Report_SortComm and(object source,
System.Web.UI.W ebControls.Data GridSortCommand EventArgs e)
{
string expr = e.SortExpressio n;
string oldexpr = (string)ViewSta te["DataSortExpres sion"];
if(oldexpr == expr)
{
ViewState["DataSortExpres sion"] = expr + " DESC";
}
else
{
ViewState["DataSortExpres sion"] = expr;
}
BindData(); // -> This creates the re-creates the columns in the
grid
}

So I put a breakpoint in the sort method and click on one of the column
titles. The data grid goes blank and my breakpoint never gets hit.

SOOO - when I remove the columns from a datagrid, does the sort event
delegate get cleared ?? How do I get the sort event to call my custom sort
handler?

Thanks

-- Jake

Nov 18 '05 #1
0 2058

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1352
by: JP011 | last post by:
Hello I have hit a major road block when it comes to building my dynamic datagrid. To make a long story short I need a dynamic datagrid because my connection string could change and I need the datagrid to handle that. First I tried to create my datagrid by leaving the auto-generate columns equal to true. This worked fine except that when my user wants to edit a line I do not want them to edit column 1, only column 2. I could not find a...
0
1021
by: Karlo Swart via .NET 247 | last post by:
Hi. I am creating a dynamic datagrid. The columns are based on a request.querystring value. Eg: I will pass in a 'func=toys' parameter, which will cause the datagrid to load create columns specific to a toys xml file I pass in. I have a problem with the sort functionality. I have created the sorting command handler and this works fine when the columns are not created dynamically. I successfully create the columns for the datagrid in the...
0
1052
by: Jordo | last post by:
Help! I have a datagrid that is being populated after a button click to fill based on parameters set by the user at run-time. I am creating the columns programmatically from a datatable and setting the sort expression there. I have AllowSort set to True but when the grid shows up, the column headers don't have the hyperlink to allow postback and sort. Any ideas? Code snippet posted below: ------------------- Private Sub...
1
1734
by: Chad Devine | last post by:
Alright, I am posting my solution to a problem I've been having. I have finally found the answer, and it took me a while so I thought I'd provide the final solution here, since it may be benificial to others and because I had to search for the solution (not the problem) in order to find a working one. I had a datagrid that wasn't sorting, the onsortcommand seemed as though it wasn't being called, and I had dynamically bound columns in...
7
1789
by: CanoeGuy | last post by:
I have been trying for the last two weeks to display a dynamic DataGrid. The data that I'm pulling from a SQL Server DB will have whole columns that will be either NULL or 0. I want to display only the fields that have actual data in them and either not display or hide the columns that have NULL or 0 values. As an example, one page may need to display a total of 5 columns and another page may need to display three columns based on the...
1
1229
by: Patrick | last post by:
I need to build a multi-lingual application with asp.net. I do not want to have a version of the application per language used. To achieve this, I have recorded in my database all the labels and messages of my application. It worked fine except that if I do my data binding at run time and display dynamically the datagrid column header according to the language selected, I loose all the features of the datagrid such as sorting, paging,...
0
1190
by: gokulrajad | last post by:
Hi there, Iam trying to create a datagrid dynamically in asp .net (C#). It contains a leftmost column with the check box and few data columns and the last column is a hyperlink column. Please find the code attached below. The sorting, paging also doesnt work. private void BuildDataGrid() {
1
7142
by: ECD | last post by:
Hello all, I can usually find solutions to my .NET problems by searching these groups, but I'm stumped on this one. I have a datagrid in VB.NET (2.0 framework). I want to disable sorting on the first column in the grid only. I havent found a way to reliably do this yet. I tried putting the following code in the datagrid's mouse down event Dim hti As DataGrid.HitTestInfo
0
2729
by: JamesOo | last post by:
I have the code below, but I need to make it searchable in query table, below code only allowed seach the table which in show mdb only. (i.e. have 3 table, but only can search either one only, cannot serch by combine 3 table) Example I have the query table below, how do I make the code to seach based on the query from this: SELECT Product.ID, Product.Description, Quantity.Quantity, Quantity.SeialNo, Quantity.SupplierID,...
0
9645
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10336
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10155
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9953
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8978
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7502
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6741
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5513
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2881
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.