PriceCheaperton
PriceCheaperton

Reputation: 5349

how to reference datatable names

Rather than referencing 0 and 1 for my rows. How do I reference the name of the columns in my data table?

txtCustomerRef.Text = dobj.GetCustomerData(selectedValue).Rows[0][0].ToString();
txtCustomerName.Text = dobj.GetCustomerData(selectedValue).Rows[1][1].ToString();

Upvotes: 1

Views: 50

Answers (1)

marc_s
marc_s

Reputation: 754388

Just use the column name for your columns:

txtCustomerRef.Text = dobj.GetCustomerData(selectedValue).Rows[0]["CustomerRef"].ToString();
txtCustomerName.Text = dobj.GetCustomerData(selectedValue).Rows[1]["CustomerName"].ToString();

Upvotes: 2

Related Questions