Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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

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

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

SQL
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
Posted
Updated 23-May-14 4:00am
v3
Comments
Emin Kokalari 23-May-14 6:46am    
are u using a database file for your records ?
Muhamad Faizan Khan 23-May-14 7:25am    
yes
agent_kruger 23-May-14 9:47am    
sir please provide your structure of database or provide an image of the datatable as we cant see what are you trying to get.

1 solution

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

C#
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... :

C#
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();



so we are getting data directly from database to textboxes or to Combobox with OleDbDataReader();
 
Share this answer
 
Comments
Muhamad Faizan Khan 7-Jun-14 10:12am    
i am not using oledb m using 3 tier architecutre
Muhamad Faizan Khan 7-Jun-14 10:13am    
objTaxingSchemeDetails.TaxSchemeId = Convert.ToInt32(cbTaxingScheme.SelectedValue);
DataTable dt = new DataTable();
dt = objTaxingSchemeDetails.TaxWithRatebyTaxingSchId();
gvTaxingScheme= dt;
this is the simple code that binding the gridview

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