Hello,
I've a datagrid whose AllowSorting property is set to True. The datagrid is
bound to northwind table suppliers. I've handled the SortCommand event of the
datagrid control. But somehow the code is not working. The SortCommand event
handler is called, but the data shown in the grid is not sorted.
I've written the following code in the asp.net web appl.
private void Page_Load(objec t sender, System.EventArg s e)
{
if (!this.IsPostBa ck)
{
sqlDataAdapter1 .Fill(dataSet11 );
DataGrid1.DataS ource = dataSet11.Suppl iers;
DataGrid1.DataB ind();
}
}
private void DataGrid1_SortC ommand(object source,
DataGridSortCom mandEventArgs e)
{
sqlDataAdapter1 .Fill(dataSet11 );
DataView dv1 = new
DataView(dataSe t11.Suppliers," ",e.SortExpress ion,DataViewRow State.CurrentRo ws);
dv1.Sort = e.SortExpressio n.ToString();
dv1.ApplyDefaul tSort = false;
DataGrid1.DataS ource = dv1;
DataGrid1.DataM ember = "Suppliers" ;
DataGrid1.DataB ind();
}
Can anybody point out the problem? The sorting works if I change the
SelectCommand property of the dataset and fill the dataset again with the new
command with an 'order by' clause. But what's wrong with the dataview
approach that I've demonstrated above?
--
Sameeksha,
MCP (.NET) 1 1583
Hello
The problem has been solved
I'd done the data binding of grid in the designer. Instead I should have
used only dynamic binding. Once I removed the binding in the designer, it
started working
Sameeksha
"Sameeksha" wrote: Hello, I've a datagrid whose AllowSorting property is set to True. The datagrid is bound to northwind table suppliers. I've handled the SortCommand event of the datagrid control. But somehow the code is not working. The SortCommand event handler is called, but the data shown in the grid is not sorted.
I've written the following code in the asp.net web appl. private void Page_Load(objec t sender, System.EventArg s e) { if (!this.IsPostBa ck) { sqlDataAdapter1 .Fill(dataSet11 ); DataGrid1.DataS ource = dataSet11.Suppl iers; DataGrid1.DataB ind(); } }
private void DataGrid1_SortC ommand(object source, DataGridSortCom mandEventArgs e) { sqlDataAdapter1 .Fill(dataSet11 ); DataView dv1 = new DataView(dataSe t11.Suppliers," ",e.SortExpress ion,DataViewRow State.CurrentRo ws); dv1.Sort = e.SortExpressio n.ToString(); dv1.ApplyDefaul tSort = false; DataGrid1.DataS ource = dv1; DataGrid1.DataM ember = "Suppliers" ; DataGrid1.DataB ind(); }
Can anybody point out the problem? The sorting works if I change the SelectCommand property of the dataset and fill the dataset again with the new command with an 'order by' clause. But what's wrong with the dataview approach that I've demonstrated above? -- Sameeksha, MCP (.NET) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: DelphiBlue |
last post by:
I have a Nested Datagrid that is using a data relations to tie the parent
child datagrids together. All is working well with the display but I am
having some issues trying to sort the child datagrid.
HTML
Datagrid1
TemplateColumn
Table
Header information
Detail Information
|
by: ChrisM |
last post by:
Can anyone please tell me what I'm doing wrong here.
I have a Windows Form with a DataGrid on it, and I'm having real problems
with the Sorting.
It is easy to reproduce the problem I have.
If you create a new Windows Application
Put a DataGrid control on it.
Put the following in the onload event of the form:
|
by: Pete Davis |
last post by:
A different question this time. I have a DataGrid bound to a collection. Is
there any way for me to allow sorting? The DataGrid.AllowSorting=true
doesn't work, but that's probably because it can't assume the data types and
thus can't sort them.
I thought about implementing IComparable, but I don't see how that would
work since it doesn't apply generically to all the fields/properties of the
class.
Thanks.
|
by: Newbie |
last post by:
i am able to allow the user to sort the columns of my datagrid, but only in
ascending order. is there a way to allow sorting in descending order? thanks
in advance.
private void Page_Load(object sender, System.EventArgs e)
{
string sTODS = "Select * From TaskOrder";
SqlConnection sqlConn = new SqlConnection(connStr);
SqlCommand sqlCMD = new SqlCommand(sTODS);
|
by: Ken Tucker |
last post by:
I've read about this issue in many articles across the net... But haven't
found a solution. I see all kinds of custom code to perform sorting with
datagrids, but my example is so simple, I must just be missing something.
Basically, I have a .aspx page that is very simple and has a simple
datagrid. All code is in the .cs page for the datagrid (hence, I'm doing all
datagrid work programmatically). The datagrid is populated from a SQL table...
| |
by: Manny Chohan |
last post by:
hi guys, my code is returning an array and i need to create datagrid so that
i can have sorting and implement prev....next function on it to navigate. is
there any way this can be done in codebehind file. I am using c#.
Thanks
Manny
|
by: DKC |
last post by:
Hi,
Using VB.NET.
I have a datagrid having a strongly typed array of objects as its data
source.
The data from the array of objects is displayed by means of a table style,
which is fine, but I cannot sort the data when I click on the column header.
I have set the tablestype.allowsorting = true, but this has no effect.
|
by: Gene Hubert |
last post by:
I'm assigning a new datasource (a datatable) to a datagrid that is
aready displayed in a form. Then I assign a new value to
CurrentRowIndex.
The datagrid always scrolls so that the new current row is visible.
However, the vertical scrollbar does not always adjust accordingly.
Upon the first instance of assigning a new datasource and setting the
currentrowindex to the _last_ record, the part of the vertical
scrollbar that can be...
|
by: stojilcoviz |
last post by:
I've a datagrid whose datasource is an arraylist object. The arraylist
holds many instances of a specific class.
I've two questions about this:
1 - Is there a way by which I can obtain a reference to the arraylist item
the current row points to?
2 - Is it possible to sort the grid?
Many thanks in advance.
|
by: GaryDean |
last post by:
I liked the DataGrid because I was familiar in walking through it to do
custom filling and retrieval of data in cases where standard binding
wouldn't do the job.
I read somewhere that the object model is the same for the datagrid and the
gridview. But as I begin to try to manually load a gridview I notice that
there is no such thing as a GridViewItem as there was a DataGridItem. So,
it's not the same.
Are there any articles or...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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...
|
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...
|
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...
|
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();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |