|
hi i m also looking for same only.
hei can u plz provide your App_Web_pagingcontrol.ascx.cdcab7d2.dll code.
one more thhing how i can integrate with datalist
i have try it but no luck
can u plz provide it its very very urgent,.
thanx .. and nice control
|
|
|
|
|
here if i use this with datalist i m getting error at PageIndex : does not exist
plz suggest
|
|
|
|
|
|
public void DataLoad()
{
using (SqlConnection sqlcon = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString))
{
sqlcon.Open();
SqlCommand cmd0 = new SqlCommand("select * from Category_Master", sqlcon);
SqlDataAdapter qs = new SqlDataAdapter(cmd0);
int r = cmd0.ExecuteNonQuery();
DataSet ds1 = new DataSet();
DataSet DS = new DataSet();
qs.Fill(ds1);
int TotalRecords = ds1.Tables[0].Rows.Count;
int PageSize = 3;
int StartIndex = 0;
int EndIndex = 0;
StartIndex = Convert.ToInt32(Convert.ToInt32(PageIndex)) * PageSize;
EndIndex = StartIndex + PageSize;
int inti = 0;
for (inti = StartIndex; inti < EndIndex && inti < ds1.Tables[0].Rows.Count; inti++)
{
if (inti == StartIndex)
{
DS.Tables.Add();
for (int i = 0; i < ds1.Tables[0].Columns.Count; i++)
{
DS.Tables[0].Columns.Add(ds1.Tables[0].Columns[i].ColumnName);
}
}
DataRow dr = DS.Tables[0].NewRow();
for (int i = 0; i < DS.Tables[0].Columns.Count; i++)
{
dr[DS.Tables[0].Columns[i].ColumnName] = ds1.Tables[0].Rows[inti][i].ToString();
}
DS.Tables[0].Rows.Add(dr);
}
DS.Tables[0].AcceptChanges();
Paging1.PageSize = PageSize;
Paging1.TotalRecord = TotalRecords;
Paging1.CurrentPage = PageIndex + 1;
Paging1.DataLoad();
int TotalPages = Paging1.TotalPages;
Paging1.Visible = true;
if (TotalPages <= 1)
{
Paging1.Visible = false;
}
if (DS.Tables[0].Rows.Count > 0)
{
DataList1.DataSource = DS.Tables[0].DefaultView;
DataList1.DataBind();
}
}
chk this out simply replace the dataload functio with this one and customize the connection strngs accrdngly and add whatever values u would le i the datalist and bind the variable with your column name and ther you go . hape coding
Anuj
|
|
|
|
|
I try this code, it works with datagridview very well
But when I use it with datalist
I got an error at
StartIndex = Convert.ToInt32(Convert.ToInt32(PageIndex)) * PageSize;
Paging1.CurrentPage = PageIndex + 1;
Paging1.CurrentPage = grdTest.PageIndex + 1;
If anyone can fix this error,
please! send me your full code.
My email is tongngocoanh@gmail.com
thanks in advance!
|
|
|
|
|
Pls Helpme DataList Paging Control or repeter control
|
|
|
|
|
Hi..
It is not possible to add in two forms in same application...Paging_Click is working in one form with datalist but Paging_Click is not firing in the other form....
|
|
|
|
|
Hi, sindhu I am using you GridView and I love it very much but i've been trying to align some row column and it does not work any idea
for instance I have you datalist paging control with the following
headers and Rows
-------------------------------------------------
ID Name City State Phone Date Exp.
-------------------------------------------------
1 abc blah Somewhere DC 666-232-222 02/20/2010
I want to be able to center the row line of the state,and ID
-------------------------------------------------
ID Name City State Phone Date Exp.
-------------------------------------------------
1 abc blah Somewhere DC 666-232-222 02/20/2010
Any suggestions
TIA
|
|
|
|
|
i implemented custom paging to fetch data. it works fine. but whenever i press Previous button In paging click event e.commandarguement becomes 0 and it throws an exception. i think a simple condition needs to be added in the code.
This is my stored procedure
Create Proc GetEmployeeListPerPage
(
@pagenumber int,
@pagesize int
)
as
begin
declare @recordFrom int,@recordTo int, @count int
set @recordFrom = ((@pagenumber -1)* @pagesize)+ 1
set @recordTo = @recordFrom + @pagesize -1
select @count = count(*) from employee
;with temp(employeeid,[name], rownum)
as
(
select employeeid, [name],row_number() over(order by employeeid) as rownum from employee
)
select @count,employeeid,[name] from temp where rownum between @recordFrom and @recordTo
end
this is the modified code. it works fine.
public void DataLoad()
{
DataSet ds = new DataSet();
ds = GetCustomPagingRecords(grdTest.PageSize, grdTest.PageIndex+1);
Paging1.PageSize = grdTest.PageSize;
Paging1.TotalRecord = Convert.ToInt32( ds.Tables[0].Rows[0][0].ToString()) ;
Paging1.CurrentPage = grdTest.PageIndex + 1;
Paging1.DataLoad();
grdTest.DataSource = ds.Tables[0].DefaultView;
grdTest.DataBind();
}
public DataSet GetCustomPagingRecords(int pageSize,int currentpagenumber)
{
DataSet DS = new DataSet();
SqlConnection Conn = new SqlConnection(connStr);
SqlCommand Comm = new SqlCommand();
Comm.Connection = Conn;
Comm.CommandType = CommandType.StoredProcedure;
Comm.CommandText = "GetEmployeeListPerPage";
Comm.Parameters.Add(new SqlParameter("@pagenumber", currentpagenumber));
Comm.Parameters.Add(new SqlParameter("@pagesize", pageSize));
SqlDataAdapter AD = new SqlDataAdapter();
AD.SelectCommand = Comm;
AD.Fill(DS);
return DS;
}
Only this following code throws an error.
public void Paging_Click(object sender, CommandEventArgs e)
{
string CurrentPage = e.CommandArgument.ToString();// becomes 0 on pressing previous button.
grdTest.PageIndex = Convert.ToInt32(CurrentPage) - 1;
DataLoad();
}
if you can provide the code it would be easier to troubleshoot this problem. else you can also have a look.
Praveen
|
|
|
|
|
Hi
Thanks for using this code.
Sorry for delay
First thing, in the code,
I have already checked,
if page 1, previous and first button enable false, there is no possibility to give error. if any case, error are there, please check all properties of aspx page and test again.
Nitin Sindhu
Team Lead
Braintechnosys, India
|
|
|
|
|
Can you please post a very Basic DataList Example? I'm trying to code it like below, but it is outputting all of the records.
Display
<table cellpadding="0" cellspacing="0" width="100%" border="0">
<tr>
<td>
<a href='test.aspx'>Refresh</a>
<asp:Label ID="lblDisplay" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td>
<uc1:PagingControl ID="Paging1" OnPaging_Click="Paging_Click" FirstString="<< First" LastString=" Last >>" NextString="Next >" PrevString="< Prev" TotalNumberPaging="20" runat="server" />
</td>
</tr>
<tr>
<td>
<asp:DataList ID="grdTest" runat="server">
<ItemTemplate><%# Eval("ID") %></ItemTemplate>
</asp:DataList>
</td>
</tr>
<tr>
<td>
</td>
</tr>
</table>
Code Behind
public int PageIndex = 0;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
lblDisplay.Controls.Add(new Sindhu.PagingControl());
DataLoad();
}
}
public void DataLoad()
{
DataSet DS = new DataSet();
DS.Tables.Add(GetData());
DataSet DS1 = new DataSet();
int TotalRecords = DS.Tables[0].Rows.Count;
int PageSize = 10;
int StartIndex = 0;
int EndIndex = 0;
StartIndex = Convert.ToInt32(Convert.ToInt32(PageIndex)) * PageSize;
EndIndex = StartIndex + PageSize;
int inti = 0;
for (inti = StartIndex; inti < EndIndex && inti < DS.Tables[0].Rows.Count; inti++)
{
if (inti == StartIndex)
{
DS1.Tables.Add();
for (int i = 0; i < DS.Tables[0].Columns.Count; i++)
{
DS1.Tables[0].Columns.Add(DS.Tables[0].Columns[i].ColumnName);
}
}
DataRow dr = DS1.Tables[0].NewRow();
for (int i = 0; i < DS.Tables[0].Columns.Count; i++)
{
dr[DS.Tables[0].Columns[i].ColumnName] = DS.Tables[0].Rows[inti][i].ToString();
}
DS1.Tables[0].Rows.Add(dr);
}
DS1.Tables[0].AcceptChanges();
Paging1.PageSize = PageSize;
Paging1.TotalRecord = TotalRecords;
Paging1.CurrentPage = PageIndex + 1;
Paging1.DataLoad();
grdTest.DataSource = DS.Tables[0].DefaultView;
grdTest.DataBind();
}
public DataTable GetData()
{
DataTable dt = new DataTable();
DataView dv = new DataView();
dt.Columns.Add(new DataColumn("ID"));
DataRow dr;
int i = 0;
for (i = 1; i <= 50; i++)
{
dr = dt.NewRow();
dr["ID"] = i.ToString();
dt.Rows.Add(dr);
}
dt.AcceptChanges();
return dt;
}
public void Paging_Click(object sender, CommandEventArgs e)
{
string CurrentPage = e.CommandArgument.ToString();
PageIndex = Convert.ToInt32(CurrentPage) - 1;
DataLoad();
}
modified on Wednesday, September 23, 2009 6:34 PM
|
|
|
|
|
In this code, you can use DS1 not DS
-----------------------------------------
grdTest.DataSource = DS.Tables[0].DefaultView;
grdTest.DataBind();
Nitin Sindhu
Team Lead
Braintechnosys, India
|
|
|
|
|
Hi, Nitin, I am trying to use your paging control but for some reason it worked for 1 day after that it stopped, it loads the records in the grid with no problem but when you are trying to move to the next paging
it goes to the last page created in the GRID explain
for instance the recordset load 50K rows in the GRID with 268 pages
your control starts the paging at the BOF #1 Page when you click on the next one or the numeric paging 1,2,3,4,5 etc it goes to the last one 268 and it does not page prev or next just refresh to original load any idea?
I am loading records from SQL database using oledbDataReader
as follow (This part works fine and show the records in the grid)
if (oRs.HasRows == true)
{
dr = dt.NewRow();
dr["ID"] = oRs["customerid"].ToString();
dr["Name"] = oRs["firstname"].ToString() + ", " + oRs["firstname"].ToString();
dr["City"] = oRs["city"].ToString();
dr["State"] = oRs["state"].ToString();
dr["Phone"] = oRs["Phone"].ToString();
dr["Preferred"] = oRs["PreferredCustomer"].ToString();
dt.Rows.Add(dr);
while (oRs.Read())
{
dr = dt.NewRow();
dr["ID"] = oRs["customerid"].ToString();
dr["Name"] = oRs["firsttname"].ToString() + ", " + oRs["firstname"].ToString();
dr["City"] = oRs["city"].ToString();
dr["State"] = oRs["state"].ToString();
dr["Phone"] = oRs["Phone"].ToString();
dr["Preferred"] = oRs["PreferredCustomer"].ToString();
dt.Rows.Add(dr);
}
oRs.Close();
}
dt.AcceptChanges();
return dt;
//- Next or Prev page or any # from the grid clicked.
public void Paging_Click(object sender, CommandEventArgs e)
{
string CurrentPage = e.CommandArgument.ToString();
grdCust.PageIndex = Convert.ToInt32(CurrentPage) - 1;
DataLoad();
}
TIA
Al
|
|
|
|
|
HI
thanx for using this code
Can you please send me the whole page code (means how to set Paging Control Properties) so that I can check the problem and send the proper change code.
Nitin Sindhu
Team Lead
Braintechnosys, India
|
|
|
|
|
Thank you much for getting back I found what is the problem when I use a Session variable it jumps to the last record of the gridview
this is what mean (this does not work)
string strConID="";
if (Session["conid"] != null)
{
strConID = Session["conid"].ToString();
}
lblDisplay.Controls.Add(new Sindhu.PagingControl());
DataLoad();
================================================================== this works fine
string strConID="SINHU01";
lblDisplay.Controls.Add(new Sindhu.PagingControl());
DataLoad();
it works fine.
any idea?
tia
|
|
|
|
|
I traced the problem and got it to work.
now I am working on column aligments some in left justified,some center and some right.
for now I can only get all of the column to justify to the left when trying to breaking them by column does not let me.
Thanks much again
|
|
|
|
|
first of all sorry for postimg message without reading all threads.
it is working superb even with ajax .
i have used and customized it .
Thanxx alot u solve our all time problem
|
|
|
|
|
hi....
is not working in datagrid
and paging not changed in datalist
please provide me full code
|
|
|
|
|
public void DataLoad()
{
using (SqlConnection sqlcon = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString))
{
sqlcon.Open();
SqlCommand cmd0 = new SqlCommand("select * from Category_Master", sqlcon);
SqlDataAdapter qs = new SqlDataAdapter(cmd0);
int r = cmd0.ExecuteNonQuery();
DataSet ds1 = new DataSet();
DataSet DS = new DataSet();
qs.Fill(ds1);
int TotalRecords = ds1.Tables[0].Rows.Count;
int PageSize = 3;
int StartIndex = 0;
int EndIndex = 0;
StartIndex = Convert.ToInt32(Convert.ToInt32(PageIndex)) * PageSize;
EndIndex = StartIndex + PageSize;
int inti = 0;
for (inti = StartIndex; inti < EndIndex && inti < ds1.Tables[0].Rows.Count; inti++)
{
if (inti == StartIndex)
{
DS.Tables.Add();
for (int i = 0; i < ds1.Tables[0].Columns.Count; i++)
{
DS.Tables[0].Columns.Add(ds1.Tables[0].Columns[i].ColumnName);
}
}
DataRow dr = DS.Tables[0].NewRow();
for (int i = 0; i < DS.Tables[0].Columns.Count; i++)
{
dr[DS.Tables[0].Columns[i].ColumnName] = ds1.Tables[0].Rows[inti][i].ToString();
}
DS.Tables[0].Rows.Add(dr);
}
DS.Tables[0].AcceptChanges();
Paging1.PageSize = PageSize;
Paging1.TotalRecord = TotalRecords;
Paging1.CurrentPage = PageIndex + 1;
Paging1.DataLoad();
int TotalPages = Paging1.TotalPages;
Paging1.Visible = true;
if (TotalPages <= 1)
{
Paging1.Visible = false;
}
if (DS.Tables[0].Rows.Count > 0)
{
DataList1.DataSource = DS.Tables[0].DefaultView;
DataList1.DataBind();
}
}
check this and u will understand the simple working and implementation of this control .. well thank you nitin for providing such a useful control in a simple manner.
this is the method u should use in the datalist to load data to the list well you can customize the source accordingly. Happy coding
Anuj
|
|
|
|
|
when i change for datalist its not working
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0029: Cannot implicitly convert type 'System.Data.DataTable' to 'System.Data.DataSet'
Source Error:
Line 30: {
Line 31: DataSet DS = new DataSet();
Line 32: DS = GetData();
Line 33:
Line 34:
|
|
|
|
|
Nice sample!
But it seems to me that part of the code is not available. I mean the code for App_Web_pagingcontrol.ascx.cdcab7d2.dll. Appreciated if you can provide it. Thanks.
|
|
|
|
|
Hi sir........
Great article................
Najmul Hoda
I want to be programmer till death.
|
|
|
|
|
Hi Sir,
we already wrote coding for insert record into MSACCESS Database using Javascript. Its working fine. But when we deploy that page into (IIS) server its trigger error in client machine. server maching ok. so we found out that problem in Connection String path. Please give me ur answer for my problem. How can get the Database Path from server using Javascript coding. or equivalent keyword for Server.MapPath.
Thanks in Advance.
Murugan.
|
|
|
|
|
can you give me a code that work with repeater in vb.net ?
and also don't use Dataset ! but use Datareader to fill Repeater rows !
my code is :
Private Sub FillRepeater(ByVal sid As String)
Using _
conn As New Data.SqlClient.SqlConnection(". . ."), _
dbCom As New Data.SqlClient.SqlCommand("", conn)
conn.Open()
Try
dbCom.CommandText = "SELECT * FROM TestTable where ID_Node_Parent = " & sid
Using dbDr As Data.SqlClient.SqlDataReader = dbCom.ExecuteReader
rpt_structure.DataSource = dbDr
rpt_structure.DataBind()
End Using
Catch
End Try
conn.Close()
End Using
End Sub
I can't use your code .
I can't speak english very well .(Sorry)
modified on Friday, December 12, 2008 11:59 PM
|
|
|
|
|
I tried Your code with Datalist
But its not working...
and also it cause error at PageIndex.....
if i use datalist code then it you are not initialize the PageIndex in the c# code...
<code><b>
so it cause error at
StartIndex = Convert.ToInt32(Convert.ToInt32(PageIndex)) * PageSize;
Paging1.CurrentPage = PageIndex + 1;
Paging1.CurrentPage = grdTest.PageIndex + 1;
</b></code>
Please Help me.. Please
|
|
|
|