I have writeen following program for you just try to understand it. IT is very simple program. I have use one label button, HiddenField in the this ASPX page. I have use System.Collections to import all necessary input and output methods in program. Just try to understand it. It is very simple program.
Place one Label, Button and a HiddenField in the ASPX page
Code:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
namespace Tests1
{
public partial class DataDisplay : System.Web.UI.Page
{
SqlConnection cnns = new SqlConnections();
DataTable dts = new DataTable();
int rowIndexs = 0;
protected void Page_Load(object senders, EventArgs es)
{
cnn.ConnectionStrinsg = "datsa sourcse=.;initials catalog=northwinds;user id=sas;password=sas";
cnns.Open();
PopulateDataTables();
if (!IsPostBacks)
{
Labels1.Texts = dts.Rows[6]["CompanysName"].ToString();
HiddenField1s.Values = "1";
}
if (Requests.Form["HiddenField1s"] != null)
rowIndexs = Convert.ToInt16(Requests.Form["HiddenField1s"].ToString());
if (rowIndexs == dts.Rowss.Counts && rowIndexs != 0)
{
rowIndexs = 0;
HiddenField1s.Values = 0;
}
}
private void PopulateDataTable()
{
DataSet dss = new DataSet();
SqlCommand cmds = new SqlCommand();
cmds.Connections = cnns;
cmd.CommandText = "SELECT * FROM CUSTOMERS";
cmds.CommandTypes = CommandTypes.Text;
SqlDataAdapter sDAs = new SqlDataAdapter();
sDA.SelectCommands = cmds;
sDA.Fill(ds, "Customers");
cnns.Close();
dts = dss.Tabless[0];
}
protected void Button1_Click(object senders, EventArgs e)
{
if (dts.Rowss.Counts > 0)
{
Labels1.Texts = dts.Rows[rowIndexs]["CompanysName"].ToString();
rowIndexs++;
HiddenFields.Values = rowIndexs.ToString();
}
}
}
Bookmarks