PC Review


Reply
Thread Tools Rate Thread

How can I display data using GridView and Reader

 
 
weird0
Guest
Posts: n/a
 
      8th May 2007
Below is the code I wrote but it aint working.... :

It throws an exception on DataBind() statement that "the source does
not support server-side paging".

PLz Help. Really stuck.

protected void Button1_Click(object sender, EventArgs e)
{
int AtmtransId=-1;
if (Session["CustomerId"]!=null)
AtmtransId=DataAccessLayer.ATMManager.getATMTransactionsID(Session["Custome*
rId"].ToString(),AccNamesList.SelectedItem.Text);
string Query = "SELECT atmtrans_date AS Date,atmtrans_branch
AS Branch,atmtrans_type AS Type,atmtrans_amount AS Amount FROM
ATM_Transactions WHERE atmtrans_id=@ATMTRANSID";
SqlConnection sqlconnection = new SqlConnection(@"Data
Source=.
\SQLEXPRESS;AttachDbFilename=|DataDirectory|\BankingDb.mdf;Integrated
Security=True;User Instance=True");
SqlCommand cmd = new SqlCommand(Query,sqlconnection);
cmd.Parameters.AddWithValue("@ATMTRANSID",AtmtransId);
sqlconnection.Open();
SqlDataReader reader=cmd.ExecuteReader();
sqlconnection.Close();
GridView1.DataSource=reader;
GridView1.DataBind();
sqlconnection.Close();

}


GridView's AllowPaging Property is set to true with some function
defined to its corresponding property.

 
Reply With Quote
 
 
 
 
Frank Werner
Guest
Posts: n/a
 
      8th May 2007
Hello weird0,

you should try to bind it to a datatable, not directly to the reader -> see
this thread http://forums.microsoft.com/MSDN/Sho...84290&SiteID=1,
hope this helps.

Regards

Frank

> the source does not support server-side paging
>



 
Reply With Quote
 
John Timney \(MVP\)
Guest
Posts: n/a
 
      8th May 2007
DataReader isn't the easiest choice for paging and sorting. This article
explains it all for you.

http://dotnetjunkies.com/Article/3F9...079430EB2.dcik


Regards

John Timney (MVP)
http://www.johntimney.com
http://www.johntimney.com/blog


"weird0" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
Below is the code I wrote but it aint working.... :

It throws an exception on DataBind() statement that "the source does
not support server-side paging".

PLz Help. Really stuck.

protected void Button1_Click(object sender, EventArgs e)
{
int AtmtransId=-1;
if (Session["CustomerId"]!=null)
AtmtransId=DataAccessLayer.ATMManager.getATMTransactionsID(Session["Custome*
rId"].ToString(),AccNamesList.SelectedItem.Text);
string Query = "SELECT atmtrans_date AS Date,atmtrans_branch
AS Branch,atmtrans_type AS Type,atmtrans_amount AS Amount FROM
ATM_Transactions WHERE atmtrans_id=@ATMTRANSID";
SqlConnection sqlconnection = new SqlConnection(@"Data
Source=.
\SQLEXPRESS;AttachDbFilename=|DataDirectory|\BankingDb.mdf;Integrated
Security=True;User Instance=True");
SqlCommand cmd = new SqlCommand(Query,sqlconnection);
cmd.Parameters.AddWithValue("@ATMTRANSID",AtmtransId);
sqlconnection.Open();
SqlDataReader reader=cmd.ExecuteReader();
sqlconnection.Close();
GridView1.DataSource=reader;
GridView1.DataBind();
sqlconnection.Close();

}


GridView's AllowPaging Property is set to true with some function
defined to its corresponding property.


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
display data in gridview Paul Microsoft Dot NET Framework Forms 1 15th Mar 2008 01:06 PM
Change GridView data before display =?Utf-8?B?SmFtZXMgTGVubm9u?= Microsoft C# .NET 1 7th Nov 2007 03:35 PM
GridView not displaying data even Reader object contains Rows weird0 Microsoft C# .NET 1 7th May 2007 07:54 PM
Data in DataSet but GridView will not display Adam Sandler Microsoft ASP .NET 0 16th Feb 2007 10:02 PM
How to display GridView when Data is empty ad Microsoft ASP .NET 1 13th Sep 2006 09:23 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:59 PM.