Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Gridview bound with Code not allowing paging

Reply
Thread Tools

Gridview bound with Code not allowing paging

 
 
jerrygp@gmail.com
Guest
Posts: n/a
 
      04-03-2007
Hello:

my problem resides on the following, off course I do dataBinding to a
gridview by a class created under Vs2005 c#.

I do databinding to my gridview smooth and works fine when i call the
method to databind to my gridview, but when I allowPaging = true by
code or by designer, and after calling the same method listed right
below, I get no data.


please see my code. Any help will be appreciated and shared with
anyone.

public Boolean gridViewDataBind(ref System.Web.UI.WebControls.GridView
myGv, string mySqlStr, string[] PkFields )
{
Boolean result = false;
if (mySqlConn.State != ConnectionState.Open)
getConnected();
try
{

SqlCommand sqlCommand = new SqlCommand(mySqlStr,
mySqlConn);
SqlDataReader dr = sqlCommand.ExecuteReader();

myGv.DataSource = dr;
myGv.DataKeyNames = PkFields; // PK field
myGv.DataBind();

myGv.AllowPaging = true;
myGv.PageSize = 10;

dr.Dispose();
sqlCommand.Dispose();
result = true;

}
catch { result = false; }


return result;

}

 
Reply With Quote
 
 
 
 
Ben Rush
Guest
Posts: n/a
 
      04-03-2007
Are you sure you're not throwing an exception somehow? It looks to me like
you're blindly swallowing your exceptions and returning the boolean False;
apart from being a bad idea to blindly swallow exceptions, that might be
your problem.

What happens if you remove the generic catch statement and just let the
function execute as-is (or place a debug break in your exception handler).

--
~~~~~~~~~~~
Ben Rush
http://www.ben-rush.net/blog


<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
> Hello:
>
> my problem resides on the following, off course I do dataBinding to a
> gridview by a class created under Vs2005 c#.
>
> I do databinding to my gridview smooth and works fine when i call the
> method to databind to my gridview, but when I allowPaging = true by
> code or by designer, and after calling the same method listed right
> below, I get no data.
>
>
> please see my code. Any help will be appreciated and shared with
> anyone.
>
> public Boolean gridViewDataBind(ref System.Web.UI.WebControls.GridView
> myGv, string mySqlStr, string[] PkFields )
> {
> Boolean result = false;
> if (mySqlConn.State != ConnectionState.Open)
> getConnected();
> try
> {
>
> SqlCommand sqlCommand = new SqlCommand(mySqlStr,
> mySqlConn);
> SqlDataReader dr = sqlCommand.ExecuteReader();
>
> myGv.DataSource = dr;
> myGv.DataKeyNames = PkFields; // PK field
> myGv.DataBind();
>
> myGv.AllowPaging = true;
> myGv.PageSize = 10;
>
> dr.Dispose();
> sqlCommand.Dispose();
> result = true;
>
> }
> catch { result = false; }
>
>
> return result;
>
> }
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

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
Lower bound & Upper bound sunil panda Java 9 10-07-2008 08:32 PM
Paging In GridView bound to DataSet ES ASP .Net Web Controls 5 10-10-2006 05:36 PM
How to represent the data in a not bound control via bound control Mario Krsnic ASP .Net 0 06-23-2006 07:38 AM
Adding paging to a Gridview Control bound to DirectoryInfo.GetFiles() pittster@hotmail.com ASP .Net 2 12-07-2005 09:03 PM
Getting lower-bound and upper-bound of strings input Rhiner Dan C++ 1 03-27-2005 02:03 AM



Advertisments