[Newbie Question] Populating Textbox.text from a dataview using columnnames?

D

DC

Is it possible to populate a list of Textbox.Text items from a dataview
using column names?

IE:

tbNameTextBox.Text = dvDataView.Table.Column("Name").ToString();
tbAddressTextBox.Text = dvDataView.Table.Column("Address").ToString();

Or someting similar?
--
_______________________________________________

DC

"You can not reason a man out of a position he did not reach through reason"

"Don't use a big word where a diminutive one will suffice."

"A man with a watch knows what time it is. A man with two watches is
never sure." Segal's Law
 
C

Chad Z. Hower aka Kudzu

DC said:
Is it possible to populate a list of Textbox.Text items from a dataview
using column names?

IE:

tbNameTextBox.Text = dvDataView.Table.Column("Name").ToString();
tbAddressTextBox.Text = dvDataView.Table.Column("Address").ToString();

Or someting similar?

foreach (Column xCol in dvDataView.Table) {
tbNameTextBox.Lines.Add(xCol.Name)
}

General syntax anyways.. you'll need to correct it to exact syntax.


--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"

Get your ASP.NET in gear with IntraWeb!
http://www.atozed.com/IntraWeb/
 
D

DC

Ive got it working to some degree but now it is returning the column
header values instead of the data for the Datarow ive extracted.

if (dvDataView.Table.Rows.Count != 0)
{

tbID.Text = dvDataView.Table.Columns["ID"].ToString();
tbSpeaker.Text = dvDataView.Table.Columns["Speaker"].ToString();
}

Returns "ID" to the tbID.Text property and "speaker" to tbSpeaker.Text
rather than the valuse held in the database row my quey has put in the
DataSet.

Im sure im doing someting rediculously sill here.

--
_______________________________________________

DC

"You can not reason a man out of a position he did not reach through reason"

"Don't use a big word where a diminutive one will suffice."

"A man with a watch knows what time it is. A man with two watches is
never sure." Segal's Law
 
C

Chad Z. Hower aka Kudzu

DC said:
tbID.Text = dvDataView.Table.Columns["ID"].ToString();
tbSpeaker.Text = dvDataView.Table.Columns["Speaker"].ToString();
}

Returns "ID" to the tbID.Text property and "speaker" to tbSpeaker.Text
rather than the valuse held in the database row my quey has put in the
DataSet.

You need to access the row - not the table itself. The table contains the column definitions, not the
data.


--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"

Develop ASP.NET applications easier and in less time:
http://www.atozed.com/IntraWeb/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top