asp.net 2.0, datasource/formview question

N

Nate Hekman

I've got an AccessDataSource configured to return a single record. I've
bound that to a FormView. Beautiful, right out of the box I get a simple
tabular display of all the fields in that record. But now I want to make
that output look nicer, and I'm running into trouble.

The record I'm displaying is a Knowledge Base article, and it has fields
such as Symptoms, Cause, and Resolution. I need to display a title,
"Symptoms", followed by the Symptoms field. But if the field is blank, I
don't want to display the title. How can I incorporate that "if" logic in a
FormView's ItemTemplate?

Two dead ends I tried were:
1) Put the title and field in an asp:panel, with Visible='<%#
Bind("Symptoms") == "" %>' or something along those lines. But apparently
we can't put logical operators in the <%# %>. (Where is the <%# syntax
described anyway? You can't do a google search for that!)
2) Code something up in the page's OnLoad(), something like: if
(AccessDataSource1["Symptoms"] == "") SymptomsPanel.Visible = false; But I
can't figure out how to get from an AccessDataSource to the DataSet it got
back from its select query. What am I missing?

Any help appreciated. Thanks.


Nate
 
B

bruce barker

lookup "Data Binding Expression Syntax". its pretty simple, though, <%# %>
fill in the Expression property of the DataBinder associated with the
control when you call DataBind. the DataBinder uses reflection to to find
the matching property or field on the Containing Page. if the language is C#
the return datatype must be compatiable with the control property being set.

-- bruce (sqlwork.com)



| I've got an AccessDataSource configured to return a single record. I've
| bound that to a FormView. Beautiful, right out of the box I get a simple
| tabular display of all the fields in that record. But now I want to make
| that output look nicer, and I'm running into trouble.
|
| The record I'm displaying is a Knowledge Base article, and it has fields
| such as Symptoms, Cause, and Resolution. I need to display a title,
| "Symptoms", followed by the Symptoms field. But if the field is blank, I
| don't want to display the title. How can I incorporate that "if" logic in
a
| FormView's ItemTemplate?
|
| Two dead ends I tried were:
| 1) Put the title and field in an asp:panel, with Visible='<%#
| Bind("Symptoms") == "" %>' or something along those lines. But apparently
| we can't put logical operators in the <%# %>. (Where is the <%# syntax
| described anyway? You can't do a google search for that!)
| 2) Code something up in the page's OnLoad(), something like: if
| (AccessDataSource1["Symptoms"] == "") SymptomsPanel.Visible = false; But
I
| can't figure out how to get from an AccessDataSource to the DataSet it got
| back from its select query. What am I missing?
|
| Any help appreciated. Thanks.
|
|
| Nate
|
|
 

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

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top