Gridview记录细节视图在文本框的 [英] Detail view of gridview record On textboxes

查看:77
本文介绍了Gridview记录细节视图在文本框的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经为Gridview制作了一个标签,第二个用于包含文本框的详细信息

我已经设置了gridview的数据源这样

 dgvhadiths.DataSource = objSearch.SelectHadithTextEnglish(); 



现在我想绑定文本框,我想如果用户在gridview中选择任何记录,那么相应的记录应显示在下一个标签的文本框

解决方案

private void MSGrid_DblClick(object sender,EventArgs e)

{

try

{

if(MSGrid.get_TextMatrix(MSGrid.Row,1)!=)

{

OleDbConnection con = new OleDbConnection(路径);

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);

else

txtOBal.Text = st1.ToString();





txtUOM.Text = dr [uom]。ToString();

st1 = double .Parse(dr [AvlQty]。ToString());

if(CheckDecimal(st1)== false)

txtAqty.Text = st1.ToString( 0);

else

txtAqty.Text = st1.ToString();



CmbTax.Text = dr [TaxType]。ToString();

txttax.Text = dr [Tax]。ToString();





}

}

}

}

catch(Exception ex)

{

MessageBox.Show(ex.Message);

}

}



i有Done Msflex网格以同样的方式你可以通过获取Row索引值

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

解决方案

private void MSGrid_DblClick(object sender, EventArgs e)
{
try
{
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");
else
txtOBal.Text = st1.ToString();


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

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


}
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}

i have Done Msflex grid In same Way u can do for datagrid by getting Row index value


这篇关于Gridview记录细节视图在文本框的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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