Click here to Skip to main content
15,899,313 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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();
Posted
Updated 4-May-11 20:12pm
v2
Comments
Toniyo Jackson 5-May-11 2:13am    
So what is your problem?
Sandeep Mewara 5-May-11 2:30am    
Code dump!

And the issue is?
Legor 5-May-11 9:00am    
Is there any question regarding this code ??

1 solution

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

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900