TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
m harb
NA
11
688
how to make next and previous row buttons work?
Sep 17 2015 9:00 AM
In i have connected SQL 2008DB with asp.net 2010 web application using c# and I can not make next and previous buttons work,
and i want to show selected row number in label1 ,
only last and first buttons are working - Help me please
and i write these codes in defualt.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Configuration;
using System.Data;
using System.IO;
namespace WebApplication1
{
public partial class _Default : System.Web.UI.Page
{
int i = 0;
DataTable dt = new DataTable();
DataSet ds = new DataSet();
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection(@"Data Source=HARB\SQLEXPRESS;Initial Catalog=daily_log_golf;Integrated Security=True");
conn.Open();
SqlDataAdapter da =new SqlDataAdapter ("select * from school", conn);
da.Fill(ds, "school");
dt = ds.Tables["school"];
}
public void Display()
{
DataRow dr = dt.Rows[i];
TextBox1.Text = dr["id"].ToString();
TextBox2.Text = dr["name"].ToString();
TextBox3.Text = dr["email"].ToString();
TextBox4.Text = dr["town"].ToString();
}
protected void firstbtn_Click(object sender, EventArgs e)
{
i = 0;
Display();
}
protected void nextbtn_Click(object sender, EventArgs e)
{
if (i < ds.Tables[0].Rows.Count - 1)
{
i++;
Display();
}
else
{
}
}
protected void previousbtn_Click(object sender, EventArgs e)
{
i++;
if (i >= 0)
{
Display();
}
}
protected void lastbtn_Click(object sender , EventArgs e)
{
i = dt.Rows.Count - 1;
Display();
}
protected void showrowbtn_Click(object sender, EventArgs e)
{
//to show selected row number in label 1
DataRow row = dt.NewRow();
dt.Rows.Add(row);
// get the index now
Label1.Text = (dt.Rows.IndexOf(row)).ToString();
}
}
}
Reply
Answers (
6
)
How to display checkedbox values in another form listbox
Article c-sharpcorner/UploadFile/raj1979/broa