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();
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)