473,385 Members | 1,355 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,385 software developers and data experts.

DataGrid Pagin Not Work

Hi there
my problem is with datagrid pagin.when i try to add the pagin feature to my
datagrid i get a strange behavior.
i will explain in details:
i wanted to allow pagin in the datagrid so i have put AllowPagin property =
true;
and then i have implemented the PageIndexChanged event handler.and made all
required changes to re-filling the datasource.in this case the pagin worked
fine.
but when i have put the AutoGenerateColumns property = false the pagin
didn't work.i don't know why this happened.i hopw that you can help me
Thanks
this is my current code:
////////////
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
if(!IsPostBack)
{
MyDataGridBind();
}
}
//Start of the MyDataGridBind() Function//
void MyDataGridBind()
{
SqlConnection sqlcon = new SqlConnection();
SqlCommand sqlcom = new SqlCommand();
SqlDataAdapter sqlDA = new SqlDataAdapter();
DataSet dsRates = new DataSet();

sqlcon.ConnectionString =
ConfigurationSettings.AppSettings["connectionString"];
sqlcom.Connection = sqlcon;
sqlcom.CommandType = CommandType.Text;
sqlcom.CommandText = "SELECT * FROM rates";
sqlDA.SelectCommand = sqlcom;
sqlDA.Fill(dsRates);
DataGrid1.DataSource = dsRates;

BoundColumn bc2 = new BoundColumn();
BoundColumn bc3 = new BoundColumn();
ButtonColumn bc5 = new ButtonColumn();

bc2.DataField = "country";
bc2.HeaderText = "Fiyat";
DataGrid1.Columns.Add(bc2);

bc3.DataField = "rate";
bc3.HeaderText = "Bilgi";
DataGrid1.Columns.Add(bc3);

bc5.ButtonType = ButtonColumnType.LinkButton;
bc5.CommandName = "SendMail";
bc5.HeaderText = "BaÅŸvur";
bc5.Text = "Satın al";
DataGrid1.Columns.Add(bc5);

DataGrid1.DataBind();
}
//End of the MyDataGridBind() Function//

private void DataGrid1_PageIndexChanged(object source,
System.Web.UI.WebControls.DataGridPageChangedEvent Args e)
{
DataGrid1.CurrentPageIndex = e.NewPageIndex;
MyDataGridBind();
}
Nov 26 '05 #1
0 905

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

Similar topics

0
by: Frosty | last post by:
Hi I am using the VS xsd designer to create a strongly typed dataset. The dataset is apparently successfully created, with no warnings or errors given. Is it not then to be expected that this...
2
by: pei_world | last post by:
I want to implement a key hit with enter to dropdown a combobox that is in the datagrid. in this case I need to override its original behaviours. I found some codes from the web. Does anyone know...
2
by: Scott | last post by:
Hi all. A few days ago i ask this question and got a good quick response. I tried out what they said and it worked. However I have now come to try the same thing in another program and it...
2
by: Marty McDonald | last post by:
When setting certain datagrid properties with the IDE (as in the property window), they don't seem to take effect. For instance, Font Name. So I have to set these via code-behind at the cell...
7
by: Scott Schluer | last post by:
Hi All, I have a functioning datagrid on "Page 1" that displays order information for a single order (this is for an e-commerce site). It's actually a combination of a couple datagrids to...
4
by: The Alchemist | last post by:
I am having a problem with a dynamically-generated Datagrid. It is important to point out that this problem does not exist with a design-time created Datagrid, but only with a dynamically generated...
1
by: alexmaster_2004 | last post by:
Hi there my problem is with datagrid pagin.when i try to add the pagin feature to my datagrid i get a strange behavior. i will explain in details: i wanted to allow pagin in the datagrid so i...
7
by: GaryDean | last post by:
I am writing a method in a component that gets passed a 1.1 Datagrid. The datagrid's columns were created at run time meaning it has no columns collection. How can I access Header and Footer...
0
by: Jyothihathwar | last post by:
Hi Friends, I am displaying data using Datagrid and i have set properties as Allow Pagin = "True" and PageSize as 10.So for ex if there are records then first 10 records will be displayed first...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: 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.