I have an ASP page.
I have some textboxes and button on that page.
textboxes shows data from database.
lets say i have 100 rows in database
Now when I run my page i want to see first row data on my page on textboxes...
and when user click next button I want to see next record (next row) in the database on those textboxes
So in short next button should bring next row from database...
how can i achieve this????
I have used a hidden value to stor row index but is doesnt give me any result:/
the next button seems to not work :(
my code till now:
namespace Csharp
{
public partial class prova : System.Web.UI.Page
{
DataSet ds;
int MaxRows = 0;
int count = 0;
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ProvaConnectionString"].ConnectionString);
con.Open();
string sql = "SELECT * FROM prova";
SqlDataAdapter da = new SqlDataAdapter(sql, con);
ds = new DataSet();
if you want show record one by one with prev/next button simply use formview with allowpaging true. Set formview1.datasource=ds ... Formview1.databind()
romkaaaa1
0 Points
1 Post
navigate to the next record of the datatable
Dec 01, 2012 08:22 AM|LINK
I have an ASP page.
I have some textboxes and button on that page.
textboxes shows data from database.
lets say i have 100 rows in database
Now when I run my page i want to see first row data on my page on textboxes...
and when user click next button I want to see next record (next row) in the database on those textboxes
So in short next button should bring next row from database...
how can i achieve this????
I have used a hidden value to stor row index but is doesnt give me any result:/
the next button seems to not work :(
my code till now:
namespace Csharp
{
public partial class prova : System.Web.UI.Page
{
DataSet ds;
int MaxRows = 0;
int count = 0;
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ProvaConnectionString"].ConnectionString);
con.Open();
string sql = "SELECT * FROM prova";
SqlDataAdapter da = new SqlDataAdapter(sql, con);
ds = new DataSet();
da.Fill(ds, "prova");
Hidden_id.Value = "0";
MaxRows = ds.Tables["prova"].Rows.Count;
navigo();
con.Close();
}
}
private void navigo()
{
txt_kodi.Value = ds.Tables["prova"].Rows[count]["Code"].ToString();
txt_persh.Value = ds.Tables["prova"].Rows[count]["Description"].ToString();
txt_pershholl.Value = ds.Tables["prova"].Rows[count]["LongDescription"].ToString();
txt_tel.Value = ds.Tables["prova"].Rows[count]["Tel"].ToString();
txt_mobile.Value = ds.Tables["prova"].Rows[count]["Mobile"].ToString();
}
protected void Button1_Click(object sender, EventArgs e)
{
}
protected void Button2_Click(object sender, EventArgs e)
{
if (Hidden_id.Value.Trim() != null)
{
bool res = int.TryParse(Hidden_id.Value, out count);
if (res == true)
{
count += 1;
if (count < MaxRows - 1)
{
navigo();
Hidden_id.Value = count.ToString();
}
}
}
}
}
}
oned_gk
All-Star
31810 Points
6505 Posts
Re: navigate to the next record of the datatable
Dec 01, 2012 11:29 AM|LINK
Frank Jiang ...
All-Star
16006 Points
1728 Posts
Microsoft
Re: navigate to the next record of the datatable
Dec 03, 2012 08:05 AM|LINK
Use suggested in the post:
http://forums.asp.net/t/1807746.aspx/1
Feedback to us
Develop and promote your apps in Windows Store