如何从datatable绑定文本框 [英] how to bind textboxes from datatable

查看:143
本文介绍了如何从datatable绑定文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个组合框,其中包含不同的征税计划选项(包括不同的税)。现在我想将税收计划的税收显示在文本框中。我怎么做这个我试过这段代码



i have a combo box which include different taxing schemed option (different taxes included). now i want to show that taxing scheme's tax into textboxes. How can i do this i have tried this code

if (cbTaxingScheme.SelectedValue != null)
objTaxingSchemeDetails.TaxSchemeId =  Convert.ToInt32(cbTaxingScheme.SelectedValue);
DataTable dt = new DataTable();
dt = objTaxingSchemeDetails.TaxWithRatebyTaxingSchId();
int toalTaxes = dt.Rows.Count;



现在dt将包含征税方案列[ taxtpe和taxrate列]我想将两个列绑定到文本框我该怎么办?

如果你有任何其他好的建议那么请分享




now dt will include taxing scheme columns [taxtpe and taxrate column] i want to bind both columns to textboxes how can i do this??
if you have any other good suggestion then please share

if(@Mode='TaxingSchemeViewbyTSID')
Begin
SELECT
--COUNT(tblTaxingSchemeDetails.TaxSchemeDetailsId) as h,
TotalRecords = COUNT(*) OVER(),
tblTaxingSchemeDetails.TaxSchemeDetailsId,
tblTaxingScheme.TaxSchemeId, 
tblTaxingScheme.TaxSchemeName, 
tblTaxingSchemeDetails.TaxType,
TaxName,
tblTaxingSchemeDetails.TaxRate
From tblTaxingScheme INNER JOIN tblTaxingSchemeDetails  
On tblTaxingScheme.TaxSchemeId = tblTaxingSchemeDetails.TaxSchemeId
INNER JOIN tblTaxType 
on tblTaxingSchemeDetails.TaxType = tblTaxType.TaxTypeID
where tblTaxingScheme.TaxSchemeId =@TaxSchemeId


End

推荐答案

直接传递数据来自数据库..

例如我们有表数据库{people}的记录:ID,NAME,AGE和表{gender}:男性,女性。

和我们的表单textBox1中有3个文本框,它们是我们的ID,textBox2和textBox3

我们有一个comboBox,它有2个项目:男性,女性



pass data directly from the database..
for example we have table database{people} with records : ID , NAME ,AGE and table{gender} with : male , female.
and we have 3 textboxes in our form textBox1 that will be our ID , textBox2 and textBox3
and we have a comboBox that will have 2 items : male,female

oleDbConnection1.Open();
string query = "select * from gender";
OleDbCommand cmd = new OleDbCommand(query, oleDbConnection1);
OleDbDataReader rd = cmd.ExecuteReader();
while (rd.Read())
{
      comboBox1.Items.Add(rd.GetValue(1).ToString());
}
rd.Close();
oleDbConnection1.Close();





和文本框......:





and for the textboxes... :

oleDbConnection1.Open();
string query = "select * from people";
OleDbCommand cmd = new OleDbCommand(query, oleDbConnection1);
OleDbDataReader rd = cmd.ExecuteReader();
rd.Read();
textBox1.text = rd.Getvalue(1).ToString();
textBox2.text = rd.Getvalue(2).ToString();
textBox3.text = rd.Getvalue(3).ToString();
lexo1.Close();
oleDbConnection1.Close();







所以我们直接从数据库获取数据文本框或带有OleDbDataReader()的Combobox;




so we are getting data directly from database to textboxes or to Combobox with OleDbDataReader();


这篇关于如何从datatable绑定文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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