如何浏览文本框 [英] how to navigate through textboxes

查看:88
本文介绍了如何浏览文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好
我试图使用文本框导航到下一条记录,但无法弄清楚如何在表格中的某些位置存储行索引
任何帮助将不胜感激
这是我正在尝试的

hi all
i am trying to navigate to the next record using textbox but could not figure out that how can i store row index some where in form
any help will be deeply appreciated
here is what i am trying

protected void btn_next_Click(object sender, EventArgs e)
   {
       string strcon = ConfigurationManager.ConnectionStrings["gallup"].ConnectionString;
       string next = "SELECT * from city_breakup";
       SqlDataAdapter dauniq = new SqlDataAdapter(next, strcon);
       DataTable tableuniq = new DataTable();
       dauniq.Fill(tableuniq);
       int i=0;
       if(i<tableuniq.Rows.Count-1){
           txtlcity.Text=tableuniq.Rows[i]["city"].ToString();
           txtsample.Text = tableuniq.Rows[i]["sample"].ToString();
       }
   }

推荐答案

您不应获取此click事件的数据.您可以在表单加载事件中执行此操作.在模块级别声明索引变量(在您的代码中为"i"),SqlDataAdapter,DataTable,并在每次单击下一步"按钮时增加它.
You should not get the data on this click event. You may do it in form load event. Declare the index variable (in your code its "i"), SqlDataAdapter, DataTable at module level and increase it with every click of "Next" button.


您可以为此使用会话

you can use session for this purpose

if(i<tableuniq.Rows.Count-1){
            if (session["Rowindex"]==null) session["Rowindex"]=i;
            txtlcity.Text=tableuniq.Rows[session["Rowindex"]]["city"].ToString();
            txtsample.Text = tableuniq.Rows[session["Rowindex"]]["sample"].ToString();
session["Rowindex"]=i+1;
        }


这篇关于如何浏览文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆