asp.net 2.0, datasource/formview question

  • Thread starter Thread starter Nate Hekman
  • Start date Start date
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
 
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
|
|
 
Back
Top