Display a record - several questions

D

David Thielen

Hi;

I have a page that displays a record. What is shown is based on the record
values - for example there is a MultiView and the View shown depends on a
value in the record.

So I cannot use a DetailsView or FormView - it's just a bunch of fields on
the page.

1) I want to call using ViewDatasource.aspx?ID=5 and I have an
ObjectDataSource set up to get the correct record on a select. But I don't
think that is happening. What do I have to do to have the select called and
the ObjectDataSource populated?

2) To display Text in a cell I put <td><%# Eval("Title") %></td> (the column
name is Title). Is this correct.

3) To pick the multiview I put <asp:MultiView ActiveViewIndex='<%#
Eval("ProviderType") %>' ... where ProviderType is an enum:int and returns 0
or 1. Is this correct?

4) How do I display a RadioButtonList and CheckBox value where it is display
only? I would like to have the radio buttons and checkbox displayed - but
they cannot be editable and disabling them looks wrong (to me). Can they be
made read-only?

5) How do I set the initial value of a RadioButtonList? I can't find a
property for that.
 
D

David Thielen

Hi;

One more

6) What is the best way to provide a message if they put ID=5 in the url and
there is no record 5?
 
S

Steven Cheng[MSFT]

Hi Dave,

Thank you for posting.

Seems you're still struggling in some web applications, as for your
questions, here are some of my general suggestion:

1) I want to call using ViewDatasource.aspx?ID=5 and I have an
ObjectDataSource set up to get the correct record on a select. But I don't
think that is happening. What do I have to do to have the select called and
the ObjectDataSource populated?
=========================================
If what you want is let teh ObjectDataSource queried the certain record
according to the page's querystring parameter, you can define a Querystring
paramter in the ObjectDatasource and map it to paramter in the SQL select
statement.

#Using Parameters with Data Source Controls
http://msdn2.microsoft.com/en-us/library/xt50s8kz(VS.80).aspx


2) To display Text in a cell I put <td><%# Eval("Title") %></td> (the
column
name is Title). Is this correct.
=========================================
Yes, Eval is the correct expression to output data from the bound record(as
long as the property name or column name is correctly specified).


3) To pick the multiview I put <asp:MultiView ActiveViewIndex='<%#
Eval("ProviderType") %>' ... where ProviderType is an enum:int and returns
0
or 1. Is this correct?
==========================================
Yes, you can do through this and I suggest you first use some "Eval" code
snippet to output it for testing. Also, for FormView or DetailsView such as
"ItemCreated" or "DataBound" where we can manually get the reference of the
sub controls in the certain tepmlate and modify them.


4) How do I display a RadioButtonList and CheckBox value where it is
display
only? I would like to have the radio buttons and checkbox displayed - but
they cannot be editable and disabling them looks wrong (to me). Can they be
made read-only?
==========================================
Based on my understanding, Radio or CheckBox control can not be set as
"readonly" , we can only make it disabled(gray), this is limited to the
HTML element's behavior. One possible means is add the "onclick"
client-side event handler for the checkbox or radio and cancel the event in
the event handler(this can make the user's clicking take no effect).


5) How do I set the initial value of a RadioButtonList? I can't find a
property for that.
==========================================
RadioButtonList derived from ListControl, so it also support the
SelectedIndex , SelectedValue property which you can have a try upon.


6) What is the best way to provide a message if they put ID=5 in the url
and
there is no record 5?
==========================================
IMO, since those ASP.NET 2.0 databound controls like GridView, FormView
support a "EmptyDataTemplate"(which is used to custom the view for non data
queried scenario), you can use this template to provide the alert info.

#FormView.EmptyDataTemplate Property
http://msdn2.microsoft.com/en-US/library/system.web.ui.webcontrols.formview.
emptydatatemplate(VS.80).aspx


If you do not want to use the databound's template, you may need to capture
the non-data event, e.g the datasource control's "Selected" event, we can
check whether there is row returned there(through the parameter in the
event) and then customize some UI element on the page to display the alert
info.

Hope this helps.

Regards,

Steven Cheng
Microsoft Online Community Support


==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================


This posting is provided "AS IS" with no warranties, and confers no rights.



Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 

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

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top