By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,890 Members | 1,097 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,890 IT Pros & Developers. It's quick & easy.

Usual Databinding Question - UNusual Requirements

P: n/a

I have a rather unusual request about a rather basic need. I need to be
able to bind data to a page, but WITHOUT using a Repeater, DataGrid or


Well, I have some formatting and JavaScript issues that require each and
every form element's ID to remain unchanged. Unfortunately, whenever
data binding occurs within a Repeater, DataList or DataGrid, the form
ID’s are changed to something different (i.e., there is additional stuff
appended to the ID name to allow ASP.NET to track it).

I know I can data bind a single item to a single form element by using
ExecuteScalar(). That is, the following works great if all I want is to
bind the contents of a single database field to a single form element:

Sub EditIntro()
Dim myConn as New
OleDbConnection(ConfigurationSettings.AppSettings( "strConn"))
Dim myCmd as New OleDbCommand("SELECT [Comment] FROM [tblIntro]", myConn)
ltrlIntro.Text = FormatData(myCmd.ExecuteScalar())
IntroComment.Text = myCmd.ExecuteScalar()
End Sub

In this example, a single database field (for which only one entry, or
row, exists) is bound to both a literal (providing an excellent preview
of the database field’s contents) as well as a form <textarea> (so that
the current contents of the database field can be displayed and any
changes updated).

However, I need to be able to bind multiple database fields of just a
single database entry (or row) to multiple literals and multiple form
fields. Since I will be calling up just one database entry, I do not
want to use a Repeater, DataList or DataGrid, since these are best used
for displaying multiple database entries and will muck up the ID’s that
are used by the form fields.

Are there any online resources that I can be pointed to? Or does anyone
have any ideas?

PS, I would like any solution, if possible, to be applicable to both
ASP.NET 1.1 as well as ASP.NET 2.0. I am building an XHTML 1.1 + CSS 2.1
compliant web app, so I need flexibility.

************************************************** *********************
* My reply-to is an automatically monitored spam honeypot. Do not use *
* it unless you want to be blacklisted by SpamCop. Please reply to my *
* first name at my last name dot org. *
************************************************** *********************
“Anyone who believes in Intelligent Design (“creationism”) is just as
ignorant and ill-educated as someone who believes that the world is
flat, that the Sun circles the Earth or that there really is a tooth
fairy. Darwinism has an overwhelming foundation of evidence that can be
tested and reproduced. Intelligent Design, on the other hand, has no
evidence at all; not one single shred of testable proof. As such,
Intelligent Design is Religious Mythology, and has no right whatsoever
to be in our Science classrooms.” - 99.99+% of Scientists
************************************************** *********************
Mignon McLaughlin once said that “A nymphomaniac is a woman [who is] as
obsessed with sex as the average man.” Unfortunately, since true
nymphomaniacs are so rare, this means that it takes an extraordinary
woman to keep up with an ordinary man.
************************************************** *********************
Feb 12 '06 #1
Share this Question
Share on Google+
2 Replies

P: n/a
try this:
Sub EditIntro()
Dim myConn as
New OleDbConnection(ConfigurationSettings.AppSettings( "strConn"))
Dim myCmd as New OleDbCommand("SELECT [Comment] FROM [tblIntro]",

Dim rdr As OleDbDataReader
rdr = myCmd.ExecuteReader()

ltrlIntro.Text = FormatData(rdr("Comment"))
IntroComment.Text = rdr("Comment")

End Sub
Now you can add more columns into your select-statement and use use them
in your program any way you want.

************************************************** **************
Tapio Kulmala

"Those are my principles. If you don't like them I have others."

- Groucho Marx
************************************************** **************
Feb 14 '06 #2

P: n/a
I'm the awkward type, so I might try and fix the other problem: your
dependency on an ID. I use classes over unique IDs for CSS, and I've
got a quick and dirty JScript function that takes an id and a tagname
and searches for matching elements, returning the first match.

Is there a similar workaround in your case?

Feb 14 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.