Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Datagrid question

Reply
Thread Tools

Datagrid question

 
 
Sanjay
Guest
Posts: n/a
 
      06-02-2004
I am a newbie. On a button click, I use the following databind for a
datagrid that works perfectly. But after that, no matter which page
number I click at the bottom, I always get the first page. The same
happens with the column header clicks to sort, reverse-sort, etc. How
can I fix this? Thanks.

void btEntry_Click(object sender, EventArgs e) {

dataSrc.SelectCommand = "SELECT * FROM [visits] where
visitedPage like @anStr";

dataSrc.Parameters.Clear();

dataSrc.Parameters.Add("@anStr", srchBox.Text);

dataGrid.DataBind();

}
 
Reply With Quote
 
 
 
 
ranganh
Guest
Posts: n/a
 
      06-02-2004
Hi

Did you write the OnPageIndexChanged functionality

the place where you declare the datagrid, include the following attribute OnPageIndexChanged="dataGrid_PageIndexChanged" and then you have to write the following in your code behin

public void dataGrid_PageIndexChanged(object s, DataGridPageChangedEventArgs e) //Function for paging


dataGrid.CurrentPageIndex = e.NewPageIndex
BindData()



 
Reply With Quote
 
 
 
 
winenthu
Guest
Posts: n/a
 
      06-02-2004
Sorry, I didn't mention that it is an mxdatagrid and I am using
webmatrix. Usually this control does an auto paging, sorting, etc. Only
when I put the AutoDataBind off and then manually bind data, the paging
features are broken. The code that you gave does not fix this.

The problem is I don't know the whole picture of how this control works,
and any books that I have read fail to give the advanced usage. If I
have changed the data source with a new select statement and now the
mxdatagrid is using that data source, how to get it to do autopaging,
etc for the new data?

Thanks.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
Reply With Quote
 
winenthu
Guest
Posts: n/a
 
      06-02-2004
I finally solved this problem by the following code modification (note
that this is mxdatagrid and not datagrid):

<code>
void Page_Load(Object sender, EventArgs E ) {
if (IsPostBack) {
dataGrid.AutoDataBind = true;
dataGrid.DataBind();
}
}

void btEntry_Click(object sender, EventArgs e) {
dataGrid.AutoDataBind = false;
dataSrc.SelectCommand = "SELECT * FROM [visits] where
visitedPage like @anStr";
dataSrc.Parameters.Clear();
dataSrc.Parameters.Add("@anStr", srchBox.Text);
dataGrid.DataBind();
}
</code>

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
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
Re: Datagrid: how cut short display of a long description in a datagrid column Brian K. Williams ASP .Net 0 03-02-2004 08:35 PM
RE: Datagrid: how cut short display of a long description in a datagrid column =?Utf-8?B?U3VyZXNo?= ASP .Net 0 03-02-2004 08:31 PM
datagrid in datagrid BK Kim ASP .Net 1 03-02-2004 06:34 AM
Call Datagrid Command column outside datagrid Dave ASP .Net 0 11-20-2003 11:11 AM
To all Gurus: How can I edit/update a DataGrid in a DataGrid (nested DataGrid)? Possible? Andreas Klemt ASP .Net Datagrid Control 0 10-08-2003 01:19 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57