Click here to Skip to main content
15,917,328 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have made to tab one for Gridview and second for Details which consist of Text boxes
I have set Datasource of gridview like this
dgvhadiths.DataSource = objSearch.SelectHadithTextEnglish();

now i want to bind for textboxes and i want if user select any record in in gridview then that appropriate record should be show on next tab's textboxes

1 solution

private void MSGrid_DblClick(object sender, EventArgs e)
if (MSGrid.get_TextMatrix(MSGrid.Row, 1) != "")
OleDbConnection con = new OleDbConnection(Path);
OleDbDataAdapter da = new OleDbDataAdapter("select * from Itemmast where icode=" + MSGrid.get_TextMatrix(MSGrid.Row, 1) + "", con);
DataSet ds = new DataSet();
da.Fill(ds, "Itemmast");
DataTable dt = ds.Tables["Itemmast"];
if (dt.Rows.Count > 0)
foreach (DataRow dr in dt.Rows)

this.Itemstab.SelectedIndex = 1;
txtICode.Text = dr["ICode"].ToString();

txtIName.Text = dr["IName"].ToString();
txtRate.Text = dr["Rate"].ToString();
double st1 = double.Parse(dr["opbal"].ToString());
if (CheckDecimal(st1) == false)
txtOBal.Text = st1.ToString("0");
txtOBal.Text = st1.ToString();

txtUOM.Text = dr["uom"].ToString();
st1 = double.Parse(dr["AvlQty"].ToString());
if (CheckDecimal(st1) == false)
txtAqty.Text = st1.ToString("0");
txtAqty.Text = st1.ToString();

CmbTax.Text = dr["TaxType"].ToString();
txttax.Text = dr["Tax"].ToString();

catch (Exception ex)

i have Done Msflex grid In same Way u can do for datagrid by getting Row index value
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