|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Display a record - several questionsI 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. 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? Show quoteHide quote "David Thielen" wrote: > 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. > > -- > thanks - dave > david_at_windward_dot_net > http://www.windwardreports.com > 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.)
DataMappingType in the DataSet Designer
One page - edit & insert UserControls and Collections Property I do I remove the style attribute from Image controls? HyperLinkField and FindControl using 'sender' object on event fires FormView - initial template UserControl Problem in designing layout of website Gridview Pager Modes |
|||||||||||||||||||||||