问题描述
我创建了一个页面,可以浏览下一个上一个第一个和最后一个
如果我直接单击按钮
但是,如果我想更改文本,则任何特定记录的数据都将按我的书面说明填入,但是如果我要转到该记录的下一个记录或该记录的前一个记录不起作用,那么任何人都可以告诉我如何去查找下一个或上一个记录我的文本更改事件后的特定记录称为............
使用系统; 使用 System.Collections.Generic; 使用 System.Linq; 使用 System.Web; 使用 System.Web.UI; 使用使用System.Web.UI.WebControls; 使用使用System.Windows.Forms; 使用 System.Data.SqlClient; 使用 System.Data; 公共 部分 类 SuppliersMaster:System.Web .UI.页面 { 数据集ds; int i; 字符串查询; erp erp = 新 erp(); // 考虑到我在此类中创建了所有方法 受保护的 无效 txtSuplId_TextChanged(对象发件人,EventArgs e) { SqlDataReader dr = erp.select1(" selectsuppmstr" ,txtSuplId.Text.Trim()); 如果(dr.HasRows) { while (dr.Read()) { txtSuplId.Text = txtSuplId.Text.ToUpper(); txtSuplName.Text =(字符串)dr [" supl_name" ].ToString(); txtAddress.Text =(字符串)dr [" supl_address" ].ToString(); txtSuplCity.Text =(字符串)dr [" supl_city" ].ToString(); txtPin.Text =(字符串)dr [" supl_pin" ].ToString(); txtSuplCountry.Text =(字符串)dr [" supl_country" ].ToString(); txtTel.Text =(字符串)dr [" supl_telephone" ].ToString(); txtFax.Text =(字符串)dr [" supl_fax" ].ToString(); } } } 公共 无效 data() { txtSuplId.Text = ds.Tables [ 0 ].rows [i] [" supl_id" ].ToString(); txtSuplName.Text = ds.Tables [ 0 ].rows [i] [" 名称> ].ToString(); txtAddress.Text = ds.Tables [ 0 ].Rows [i] [" 供应地址" ].ToString(); txtSuplCity.Text = ds.Tables [ 0 ].Rows [i] [" supl_city" ].ToString(); txtPin.Text = ds.Tables [ 0 ].rows [i] [" supl_pin" ].ToString(); txtSuplCountry.Text = ds.Tables [ 0 ].Rows [i] [" supl_country" ].ToString(); txtTel.Text = ds.Tables [ 0 ].rows [i] [" supl_telephone" ].ToString(); txtFax.Text = ds.Tables [ 0 ].rows [i] [" supl_fax" ].ToString(); } 受保护的 无效 btnFirst_Click(对象发件人,EventArgs e) { ds = erp.fillds(" navigationitemmstr" ); // 存储过程 如果(ds.Tables [ 0 ].Rows.Count> 0) { i = 0 ; 数据(); btnFirst.Focus(); } querystring [" id" ] = i; } 受保护的 无效 btnLast_Click(对象发件人,EventArgs e) { ds = erp.fillds(" navigationitemmstr" ); // 存储过程 如果(ds.Tables [ 0 ].Rows.Count > 0 ) { i = ds.Tables [ 0 ].Rows.Count-1; 数据(); btnLast.Focus(); } } 受保护的 无效 btnPrev_Click(对象发件人,EventArgs e) { ds = erp.fillds(" navigationitemmstr" ); // 存储过程 如果(request.querystring [" id" ]!== 为空) {i = request.querystring [" id" ].toString(); } 如果(i == ds.Tables [ 0 ].Rows.Count-1 || i!= 0 ) { 如果(i!= 0 ) { 一世 - ; 数据(); btnPrev.Focus(); } querystring [" id" ] = i; } } 受保护的 无效 btnNext_Click(对象发件人,EventArgs e) { 如果(request.querystring [" id" ]!== 为空) {i = request.querystring [" id" ].toString(); } ds = erp.fillds(" navigationitemmstr" ); // 存储过程 如果(i < ds.Tables [ 0 ].Rows.Count- 1 ) { i ++; 数据(); btnNext.Focus(); } querystring [" id" ] = i; } }
我用过querystring如果它们是另一种方法,请告诉我
代码块语言已更改:从HTML到C#[/编辑]
I have create a page that can navigate next previous first and last
Its working If i directly click on button
But if i want on text change of any particular record data will fill as i written but if i want to next of that record or previous of that record its not working so please any one can tell me how can i go next or previous record of particular record after my text change event called.....................
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.Data; public partial class SuppliersMaster : System.Web.UI.Page { DataSet ds; int i; string query; erp erp = new erp(); //consider i hv created all methods in this class protected void txtSuplId_TextChanged(object sender, EventArgs e) { SqlDataReader dr = erp.select1("selectsuppmstr", txtSuplId.Text.Trim()); if (dr.HasRows) { while (dr.Read()) { txtSuplId.Text = txtSuplId.Text.ToUpper(); txtSuplName.Text = (string)dr["supl_name"].ToString(); txtAddress.Text = (string)dr["supl_address"].ToString(); txtSuplCity.Text = (string)dr["supl_city"].ToString(); txtPin.Text = (string)dr["supl_pin"].ToString(); txtSuplCountry.Text = (string)dr["supl_country"].ToString(); txtTel.Text = (string)dr["supl_telephone"].ToString(); txtFax.Text = (string)dr["supl_fax"].ToString(); } } } public void data() { txtSuplId.Text = ds.Tables[0].Rows[i]["supl_id"].ToString(); txtSuplName.Text = ds.Tables[0].Rows[i]["supl_name"].ToString(); txtAddress.Text = ds.Tables[0].Rows[i]["supl_address"].ToString(); txtSuplCity.Text = ds.Tables[0].Rows[i]["supl_city"].ToString(); txtPin.Text = ds.Tables[0].Rows[i]["supl_pin"].ToString(); txtSuplCountry.Text = ds.Tables[0].Rows[i]["supl_country"].ToString(); txtTel.Text = ds.Tables[0].Rows[i]["supl_telephone"].ToString(); txtFax.Text = ds.Tables[0].Rows[i]["supl_fax"].ToString(); } protected void btnFirst_Click(object sender, EventArgs e) { ds = erp.fillds("navigationitemmstr"); //store procedure if (ds.Tables[0].Rows.Count>0) { i = 0; data(); btnFirst.Focus(); } querystring["id"]=i; } protected void btnLast_Click(object sender, EventArgs e) { ds = erp.fillds("navigationitemmstr"); //store procrdure if (ds.Tables[0].Rows.Count > 0) { i = ds.Tables[0].Rows.Count-1; data(); btnLast.Focus(); } } protected void btnPrev_Click(object sender, EventArgs e) { ds = erp.fillds("navigationitemmstr"); //store procedure if(request.querystring["id"]!=null) { i=request.querystring["id"].toString(); } if (i==ds.Tables[0].Rows.Count-1||i!=0) { if (i!=0) { i--; data(); btnPrev.Focus(); } querystring["id"]=i; } } protected void btnNext_Click(object sender, EventArgs e) { if(request.querystring["id"]!=null) { i=request.querystring["id"].toString(); } ds = erp.fillds("navigationitemmstr"); //store procedure if (i < ds.Tables[0].Rows.Count - 1 ) { i++; data(); btnNext.Focus(); } querystring["id"]=i; } }
I have used querystring if their is another method please tell me
[Edit]Code block language changed: from HTML to C#[/Edit]
这篇关于Asp.net导航按钮下一步以前的帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!