Hi I really can't figure out what's wrong with my code
<asp:datagrid id="DataGrid1" runat="server"
AllowPaging="True"
AllowSorting="True"
AutoGenerateColumns="True"
OnPageIndexChanged="ChangeIndex">
<PagerStyle Mode="NumericPages"></PagerStyle>
....
private void Page_Load(object sender, System.EventArgs e)
{
if (!Page.IsPostBack)
{
this.sqlConnection1 = new SqlConnection (DBConstant.connectionDB);
this.sqlConnection1.Open ();
HttpCookie cookie = Request.Cookies["hopitalID"];
strCookieValue = cookie.Value.ToString(); fillData ();
DataGrid1.CurrentPageIndex = 1;
}
}
private void fillData ()
{
string sql = "SELECT DISTINCT FACTURE.ID_NR_FACTURE, " +
"ANALYSE.ID_ANALYSE, FACTURE.DATE_FACTURE " +
"AS DATE_FACTURE, PATIENT.PRENOM_PATIENT, " +
"PATIENT.NOM_PATIENT ,FACTURE.FACTURE, " +
"FACTURE.ACQUITTE FROM PATIENT, LABORATOIRE, " +
"ANALYSE, FACTURE WHERE ANALYSE.ID_ANALYSE = " +
"FACTURE.ID_ANALYSE AND ANALYSE.ID_PATIENT = " +
"PATIENT.ID_PATIENT AND ANALYSE.LABO_ID = " +
"LABORATOIRE.ID_LABORATOIRE AND " +
"LABORATOIRE.DESIGNATION_LABORATOIRE = '" +
strCookieValue + "'" ;
DataSet ds = new DataSet ();
SqlDataAdapter adapter = new SqlDataAdapter (sql, this.sqlConnection1);
adapter.Fill (ds);
this.DataGrid1.DataSource = ds;
this.DataGrid1.DataBind();
}
protected void ChangeIndex(object source,
System.Web.UI.WebControls.DataGridPageChangedEvent Args e)
{
DataGrid1.CurrentPageIndex = e.NewPageIndex;
fillData ();
}
really thanks in advance 2 2150
Dear Alexandre,
Change your Paging method's access level to public, as follows:-
public void ChangeIndex(object source,
System.Web.UI.WebControls.DataGridPageChangedEvent Args e)
{
DataGrid1.CurrentPageIndex = e.NewPageIndex;
fillData ();
}
That should solve your problem.
Thanks.
"Alexandre Jaquet" wrote: Hi I really can't figure out what's wrong with my code
<asp:datagrid id="DataGrid1" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="True" OnPageIndexChanged="ChangeIndex"> <PagerStyle Mode="NumericPages"></PagerStyle> ...
private void Page_Load(object sender, System.EventArgs e) { if (!Page.IsPostBack) { this.sqlConnection1 = new SqlConnection (DBConstant.connectionDB); this.sqlConnection1.Open (); HttpCookie cookie = Request.Cookies["hopitalID"]; strCookieValue = cookie.Value.ToString(); fillData (); DataGrid1.CurrentPageIndex = 1; } }
private void fillData () { string sql = "SELECT DISTINCT FACTURE.ID_NR_FACTURE, " + "ANALYSE.ID_ANALYSE, FACTURE.DATE_FACTURE " + "AS DATE_FACTURE, PATIENT.PRENOM_PATIENT, " + "PATIENT.NOM_PATIENT ,FACTURE.FACTURE, " + "FACTURE.ACQUITTE FROM PATIENT, LABORATOIRE, " + "ANALYSE, FACTURE WHERE ANALYSE.ID_ANALYSE = " + "FACTURE.ID_ANALYSE AND ANALYSE.ID_PATIENT = " + "PATIENT.ID_PATIENT AND ANALYSE.LABO_ID = " + "LABORATOIRE.ID_LABORATOIRE AND " + "LABORATOIRE.DESIGNATION_LABORATOIRE = '" + strCookieValue + "'" ; DataSet ds = new DataSet (); SqlDataAdapter adapter = new SqlDataAdapter (sql, this.sqlConnection1); adapter.Fill (ds); this.DataGrid1.DataSource = ds; this.DataGrid1.DataBind(); }
protected void ChangeIndex(object source, System.Web.UI.WebControls.DataGridPageChangedEvent Args e) { DataGrid1.CurrentPageIndex = e.NewPageIndex; fillData (); }
really thanks in advance
Thanks for your response but it's still doesn't work, I just open a book
about asp.net and they purpose another solution but still doesn't work ...
If someone have a working sample it's would be great
"ranganh" wrote: Dear Alexandre,
Change your Paging method's access level to public, as follows:-
public void ChangeIndex(object source, System.Web.UI.WebControls.DataGridPageChangedEvent Args e) { DataGrid1.CurrentPageIndex = e.NewPageIndex; fillData (); }
That should solve your problem.
Thanks.
"Alexandre Jaquet" wrote:
Hi I really can't figure out what's wrong with my code
<asp:datagrid id="DataGrid1" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="True" OnPageIndexChanged="ChangeIndex"> <PagerStyle Mode="NumericPages"></PagerStyle> ...
private void Page_Load(object sender, System.EventArgs e) { if (!Page.IsPostBack) { this.sqlConnection1 = new SqlConnection (DBConstant.connectionDB); this.sqlConnection1.Open (); HttpCookie cookie = Request.Cookies["hopitalID"]; strCookieValue = cookie.Value.ToString(); fillData (); DataGrid1.CurrentPageIndex = 1; } }
private void fillData () { string sql = "SELECT DISTINCT FACTURE.ID_NR_FACTURE, " + "ANALYSE.ID_ANALYSE, FACTURE.DATE_FACTURE " + "AS DATE_FACTURE, PATIENT.PRENOM_PATIENT, " + "PATIENT.NOM_PATIENT ,FACTURE.FACTURE, " + "FACTURE.ACQUITTE FROM PATIENT, LABORATOIRE, " + "ANALYSE, FACTURE WHERE ANALYSE.ID_ANALYSE = " + "FACTURE.ID_ANALYSE AND ANALYSE.ID_PATIENT = " + "PATIENT.ID_PATIENT AND ANALYSE.LABO_ID = " + "LABORATOIRE.ID_LABORATOIRE AND " + "LABORATOIRE.DESIGNATION_LABORATOIRE = '" + strCookieValue + "'" ; DataSet ds = new DataSet (); SqlDataAdapter adapter = new SqlDataAdapter (sql, this.sqlConnection1); adapter.Fill (ds); this.DataGrid1.DataSource = ds; this.DataGrid1.DataBind(); }
protected void ChangeIndex(object source, System.Web.UI.WebControls.DataGridPageChangedEvent Args e) { DataGrid1.CurrentPageIndex = e.NewPageIndex; fillData (); }
really thanks in advance This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: RelaxoRy |
last post by:
sqlConnection1.Open();
myReader = sqlCommand1.ExecuteReader();
DataGrid1.DataSource = myReader;
DataGrid1.DataBind();
myReader.Close();
sqlConnection1.Close();
The Datagrid populates fine. ...
|
by: Joseph D. DeJohn |
last post by:
I am trying to get pagination working on a datagrid. Can anyone point me to
a resource for help on this? I'm not sure if custom paging is the best
option or not.
|
by: enak |
last post by:
I can not get my datagrid to page. I have a datagrid that
I can sort 2 of the columns. This works great. I added
paging and when I display the dg it shows 5 pages. (I am
showing page numbers at...
|
by: RJN |
last post by:
Hi
Sorry for posting again.
I have a datagrid which is put inside a div tag to make it scrollable. I
need to page the datagrid. The page numbers appear at the bottom of the
datagrid and has...
|
by: Shawn |
last post by:
Hi.
I already have a datagrid where I'm using paging. I have a stored procedure
that fills a temp table with 200-500 rows and then sends back 10 records at
the time. When I go to page 2 the SP...
|
by: quanga |
last post by:
Hi-
I have a datagrid that in some cases can be several thousand rows in
length. What I'd like it to do is have the data pushed to the browser
after every, say, 100 rows or so. Kind of a...
|
by: Axel Dahmen |
last post by:
Hi,
I'm using a DataGrid control to show a table's content with paging. For
navigation through the pages I'm using the DataGrid's intrinsic navigation
section.
My problem: The DataGrid...
|
by: tshad |
last post by:
Is there a way to carry data that I have already read from the datagrid from
page to page?
I am looking at my Datagrid that I page through and when the user says get
the next page, I have to go...
|
by: Pat |
last post by:
I have 3 Datagrid nested.
Master
Details
Child
The master has paging (And i'm using the paging inbuilt in the Datagrid)
in the Master DataGrid you select a linkbutton(using commandname) and it...
|
by: Pat |
last post by:
I have a 2 nested Datagrid. When i select a row in the Master Datagrid i
populate the Child databrid using myDataGrid.SelectedIndex value
as the filter and setting the DataKeyField.
I enabled...
|
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...
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
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...
|
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...
| |