文本框动态生成的文本框的textchange [英] textchange for dynamic generated row of textbox

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

问题描述

int rowindex = 0;
            // if (ViewState["CurrentTable"] != null)
            // {
            // DataTable dt =new DataTable("tblAcHedas");// ((DataTable)ViewState["CurrentTable"]);
            // DataRow dr = null;
            // if (dt.Rows.Count > 0)
            // {

            // for (int i = 1; i <= dt.Rows.Count; i++)
            // {

            TextBox box1 = (TextBox)GridView1.Rows[rowindex].Cells[1].FindControl("TxT_AcC");
            TextBox box2 = (TextBox)GridView1.Rows[rowindex].Cells[3].FindControl("TxtDesc");

            //dr = dt.NewRow();
            // dt.Rows[i-1]["Column1"] = box1.Text;
            // dt.Rows[i-1]["Column3"] = box2.Text;

            //rowindex++;
            DataTable dt = new DataTable("tblAcHedas");// ((DataTable)ViewState["tblAcHedas"]);

            //DataRow dr = null;
            SqlConnection connection = new SqlConnection("Data Source=NABIN;Initial Catalog=AcDb;User ID=sa;Password=sic");
            connection.Open();
            SqlCommand sqlCmd = new SqlCommand("SELECT * FROM tblAcHedas WHERE AccCode= @AccCode", connection);
            SqlDataAdapter sqlDa = new SqlDataAdapter(sqlCmd);
            sqlCmd.Parameters.AddWithValue("@AccCode", box1.Text);
            sqlDa.Fill(dt);

            // box2.Text = dt.Rows[rowindex]["AccName"].ToString(); //Where ColumnName is the Field from the DB that you want to display

            if (dt.Rows.Count > 0)
            {
                box2.Text = dt.Rows[0]["AccName"].ToString();
                ViewState["tblAcHeads"] = dt;

                // EnableViewState = true;

            }
            connection.Close();

解决方案

jst获取行索引.能否让我详细了解您到底想要什么.您是否在griedview中动态生成行. /blockquote>

int rowindex = 0;
            // if (ViewState["CurrentTable"] != null)
            // {
            // DataTable dt =new DataTable("tblAcHedas");// ((DataTable)ViewState["CurrentTable"]);
            // DataRow dr = null;
            // if (dt.Rows.Count > 0)
            // {

            // for (int i = 1; i <= dt.Rows.Count; i++)
            // {

            TextBox box1 = (TextBox)GridView1.Rows[rowindex].Cells[1].FindControl("TxT_AcC");
            TextBox box2 = (TextBox)GridView1.Rows[rowindex].Cells[3].FindControl("TxtDesc");

            //dr = dt.NewRow();
            // dt.Rows[i-1]["Column1"] = box1.Text;
            // dt.Rows[i-1]["Column3"] = box2.Text;

            //rowindex++;
            DataTable dt = new DataTable("tblAcHedas");// ((DataTable)ViewState["tblAcHedas"]);

            //DataRow dr = null;
            SqlConnection connection = new SqlConnection("Data Source=NABIN;Initial Catalog=AcDb;User ID=sa;Password=sic");
            connection.Open();
            SqlCommand sqlCmd = new SqlCommand("SELECT * FROM tblAcHedas WHERE AccCode= @AccCode", connection);
            SqlDataAdapter sqlDa = new SqlDataAdapter(sqlCmd);
            sqlCmd.Parameters.AddWithValue("@AccCode", box1.Text);
            sqlDa.Fill(dt);

            // box2.Text = dt.Rows[rowindex]["AccName"].ToString(); //Where ColumnName is the Field from the DB that you want to display

            if (dt.Rows.Count > 0)
            {
                box2.Text = dt.Rows[0]["AccName"].ToString();
                ViewState["tblAcHeads"] = dt;

                // EnableViewState = true;

            }
            connection.Close();

解决方案

jst get the row index.can u let me know in detail what exactly you want.are you generating rows dynamicaly in griedview.


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

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