473,382 Members | 1,367 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Problem Sorting a DataGrid

I'm setting up a datagrid and am trying to sort it using what is
essentially code taken straight from the .NET framework documentation.
I used Visual Studio to build the data source itself, which I fill and
bind in Page_Load.

private void Page_Load(object sender, System.EventArgs e)
{
if (!IsPostBack)
{
sdaHIMS.Fill(dsHIMS);
dgLeases.DataBind();
Session["Source"] = dsHIMS.Tables[0];
}
}

Okay so far, the datagrid populates. AllowSorting is true and I have
Sort_Click defined to handle sorting:

private void Sort_Click(object s, DataGridSortCommandEventArgs e)
{
DataTable dt = (DataTable)Session["Source"];
DataView dv = new DataView(dt);
dv.Sort = e.SortExpression;
dgLeases.DataSource = dv;
dgLeases.DataBind();
}

That's almost exactly what's in the documentation. On the databind,
however, I get nothing but the datagrid's headers--no data appears.
I've added debug lines to Sort_Click, checking dv.Table.TableName,
dv.Table.Rows.Count, etc. They show that the table and its data are
there, but I lose it all on the databind. Does anyone know what's
happening?

Thanks, Steve
Nov 18 '05 #1
0 782

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

Similar topics

0
by: Kshitij | last post by:
Hi, I'm having a datagrid. I'm addng the columns at runtime to the datagrid.But the problem comes during sorting.It doesn't enable the sort column link.Any help on this. Here is my code. ...
0
by: Kshitij | last post by:
Hi, I am having a datagrid with one ButtonColumn and 3 BoundColumn.I want to do sorting for each column.I have set 'AllowSorting' property of the datagrid to 'true'. Also I have specified the...
2
by: Hajime Kusakabe | last post by:
Hi. I have created a datagrid (datagrid1) without any columns on a aspx page. Then aspx.vb adds columns from a database. It is somthing like this .... ================================== Dim...
1
by: bredal Jensen | last post by:
Hello, I'am experiencing that Asp.net can not handle sorting of datagrid when the number of items exceed a few thousands. Is anyone aware of this problem? The sorting works fine when the number...
8
by: simchajoy2000 | last post by:
I thought the only thing I had to do to disable column sorting in VB.NET was to set datagrid.AllowSorting = False. Unfortunately this has never worked for me. I discovered another set of code...
3
by: Gidi | last post by:
Hi, I've a dataGrid, and When I click with the mouse on one of it's header the DataGrid_Click event is called. I don't have problem with the event, but strange things happen to the dataGrid...
1
by: Mark Gilkes | last post by:
I have a DataGrid which I am adding to the page dynamically at the Init stage of the page load. The DataGrid has AutoGenerateColumns turned off, has BoundColumns and is bound to a DataView for...
0
by: rupalirane07 | last post by:
Both grids displays fine. But the problem is only parent datagrid sorting works fine but when i clik on child datagrid for sorting it gives me error: NullReferenceException error Any...
1
by: Ahmed Yasser | last post by:
Hi all, i have a problem with the datagridview sorting, the problem is a bit complicated so i hope i can describe in the following steps: 1. i have a datagridview with two columns...
0
by: alberto | last post by:
I create a DataTable dataTable. Then a BindingSource bindingSource = new BindingSource(dataTable, "") Then: dataGrid.DataSource = bindingSource. All works nicely, navigating the dataGrid...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.