473,396 Members | 2,017 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,396 software developers and data experts.

getdata() - where is this to be defined?

jrl
I am working with a code snippet from a site
(http://www.gridviewguy.com/ArticleDetails.aspx?articleID=176_Sorting_GridView _Manually!)
as follows:

private void SortGridView(string sortExpression,string direction)
{

// You can cache the DataTable for improving performance

DataTable dt = GetData().Tables[0];

DataView dv = new DataView(dt);

dv.Sort = sortExpression + direction;

GridView1.DataSource = dv;

GridView1.DataBind();

}

But I can't get it to compile (in C#) because it doesn't understand the
GetData() function in the line:
DataTable dt = GetData().Tables[0];

What would I need to include or change to help it understand this line?

Jan 24 '08 #1
3 5783
How about looking at the GetData() method, the first thing in the
page?

btw, since DataView supports IBindingList for sorting, there may be
alternatives to strings [just for completeness]:

DataTable dt = null; // todo...
IBindingList bl = dt.DefaultView;
ListSortDirection direction = ListSortDirection.Ascending;
PropertyDescriptor property =
TypeDescriptor.GetProperties(bl)["SomeColumn"];
bl.ApplySort(property, direction);
// now use as a data source

Marc
Jan 24 '08 #2
Hi,
You need the code for that method. from the code you posted it seems that it
returns a dataset from where you are getting the first table. Most probably
it use DataAdapter.Fill to get data from a database

--
Ignacio Machin
http://www.laceupsolutions.com
Mobile & warehouse Solutions.
"jrl" <jr*@newsgroup.nospamwrote in message
news:S2Zlj.849$4w.281@pd7urf2no...
>I am working with a code snippet from a site
(http://www.gridviewguy.com/ArticleDetails.aspx?articleID=176_Sorting_GridView _Manually!)
as follows:

private void SortGridView(string sortExpression,string direction)
{

// You can cache the DataTable for improving performance

DataTable dt = GetData().Tables[0];

DataView dv = new DataView(dt);

dv.Sort = sortExpression + direction;

GridView1.DataSource = dv;

GridView1.DataBind();

}

But I can't get it to compile (in C#) because it doesn't understand the
GetData() function in the line:
DataTable dt = GetData().Tables[0];

What would I need to include or change to help it understand this line?

Jan 24 '08 #3
jrl
thank you all who responded, this makes sense now.

Jan 27 '08 #4

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

Similar topics

6
by: Andy | last post by:
I'm making a drag and drop application, and in the *_DragDrop(...)-method I have the following code: private void SelectTree_DragDrop(object sender, System.Windows.Forms.DragEventArgs e) {...
2
by: Simon | last post by:
I have done a screen clipping in oneNote and now want to save to file. So I copy the image in oneNote, and then using c# try and getData from the clipboard and store in an image to be able to...
3
by: nAmYzArC | last post by:
Hello every1, I have a "<DIV" tag with contenteditable turned on. I am using this as an area that users can either paste or drag/drop text into. The text can come from other browser windows and of...
11
by: nAmYzArC | last post by:
Hi all, On our site we have a section that allows users to copy and paste or drag and drop the contents of (pretty much any) webpage into a Div. I need to get access to the clipboard data. To do...
4
by: Piotrek | last post by:
Hi all. I am developing some web application in which I use datasets, which were generated using dataSetDesigner. My dataset has a TableAdapter, which has GetData method. Users of my application...
6
by: Screaming Eagles 101 | last post by:
Hi, I got this warning, but I don't have a clue on how to resolve it the best way, maybe one of you can help. Application is running smoothly, it's only a warning, but I'd like to resolve it. ...
2
by: Martin Arvidsson | last post by:
Hi! When you use the wizard to create a connection to a table you automaticly get two methods. Fill and GetData When do you use the GetData method? Thanx
4
by: dwhalen | last post by:
Hi Everyone. I'm new to drag-and-drop, and I'm running into a problem getting some code I found to work in FireFox. I have a third-party Tree control that accepts droppable items that implement...
0
by: =?ISO-8859-1?Q?=22Ro=DFert_G=2E_Schaffrath=22?= | last post by:
Sorry for the cross-posting. I am having a hard time trying to classify exactly what group this question would apply to. I had posted an earlier message to...
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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...

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.