I looking forward to find a suitable asp.net DataBound control (C#) to implement in my application.
I wanted to create a exam page where each page show 10 questions, each question got a Label control and a radiobutton control to display the choices, the data to be bind into the DataBound control might be having multiple rows where each rows represent each question.
I found that DetailView control was quite suit with my requirement but I not able to set the page size.
Please help to give some suggestion and advises, thank you in advanced.
I would use a DataList or a ListView, because it will allow you to enter a template for each item. The reason I would choose these over a repeater is because you can use data keys, which will probably come in handy.
Here's a simple example of how you could implement a list of questions:
<asp:DataList ID="DataList1" runat="server" DataKeyField="QuestionID" ...>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%#Eval("Question")%>' />
<asp:RadioButton ID="RadioButton1" runat="server" Text="Yes" GroupName="QuestionAnswer" ... />
<asp:RadioButton ID="RadioButton2" runat="server" Text="No" GroupName="QuestionAnswer" ... />
</ItemTemplate>
</asp:DataList>
I would recommend to you to use the Repeater control since you can customize it's design very easily to suit your needs.
Here are two tutorials on how to use it:
http://www.w3schools.com/aspnet/aspnet_repeater.asp
http://www.learn-asp.net/asptutorials/Repeater.aspx
Update:
Repeater doesn't have pagination included so you would have to add it:
http://blog.divergencehosting.com/2009/03/25/adding-paging-repeater/
Other option would be to just use a GridView which has pagination included.
Related
Is it possible to place a dropdown arrow in RadAutocomplete textbox, so that user can see what options are the list? Please see the screen shot
<telerik:RadAutoCompleteBox
id="Variants"
runat="server"
skin="Silk" EmptyMessage="Type here" DropDownPosition="Static" DropDownHeight="200px">
The Telerik doco states it's not possible to browse the items in the dropdown area when using a RadAutoCompleteBox.
See here: http://www.telerik.com/help/aspnet-ajax/autocompletebox-difference-with-combobox.html
I prefer using a regular RadComboBox with the following attributes e.g.
<telerik:RadComboBox runat="server" ID="ddlVariants" AppendDataBoundItems="True" EmptyMessage="Type or select a variant" MarkFirstMatch="True" AllowCustomText="True" Width="200px" CheckBoxes="True" />
This approach still allows multiple selection and dynamic filtering of items, with the ability to expand the items to manually search if required.
in my webpage different users can visit same profile, but users can be ither Owner of a profile, or Visitors, and content have to change for those two conditions.
if visitor check profile he see this editor:
<asp:Repeater id="UserLoginRepeater" runat="server">
<HeaderTemplate>
</HeaderTemplate>
<ItemTemplate>
<asp:Label ID="Label2" runat="server">label Text</asp:Label> <asp:Label runat="server">label text 2</asp:Label>
</br>
<asp:Button runat="server" Text="TestButton"/>
</br>
<asp:Label ID="Label3" runat="server">Test</asp:Label> <textarea><%# Eval("Content") %></textarea>
</br>
</br>
</ItemTemplate>
<FooterTemplate>
</FooterTemplate>
</asp:Repeater>
codebehinde:
if User is Owner of a profile TextArea have to be replaced by a label and an other label with textbox have to be added.
I found couple of possible implementations of this on internet, but they are not so easy to maintain. for example
http://tinyurl.com/9764eys
What would be the best way to Load controls dynamicly into Repeater?
Use a <asp:ContentPlaceholder> then in your code behind add a handler for the OnItemDataBound event. If you want those controls to handle events, make sure you bind your repeater before OnPreRender for the page.
Why not just create two repeaters for two conditions?
Just bind the repeater for the specific user and hide the other one.
Made Dynamic load of Controllers in code-behinde.
I am new to asp.net and even though I have been successfully developing some decent pages
that access backend SQL server using C# code behind, I have run into a problem that I need
some nudge in the right direction on.
I need to be able to display records from a SQL datasource (could be displayed using SQLDataSource method
OR using a dataReader OR using a gridview data fill) onto a page but I need other information displayed above
and below the returned record. Its best if I show an example:
<horizontal seperator line>
Customer ID
Customer Name
Customer Address
City, ST
COLUMNS FOR THE RETURNED RECORD DATA
THE ACTUAL RECORD DATA
OTHER DYNAMICALLY CALCULATED DATA BELOW THE RECORDS
<horizontal seperator line>
And this repeats for every record that is returned
For the life of me, I can't find determine what view, template, or even best data binder or
data source control it is that I need to use to make this happen.
Thanks for anyone's assistance in advance.
dell
If a datatable or gridview won't do, you can always use a Repeater or a Listview.
In the template, you can have all the controls you want in there.
You probably need a repeater similar to this:
<asp:Repeater runat="server" ID="repeater1">
<ItemTemplate>
<hr/>
<asp:Label runat="server" ID="labelCustomerId" />
<div style="padding-left:150px">
<asp:Label runat="server" ID="labelCustomerName" />
<asp:Label runat="server" ID="labelCustomerAddress" />
<asp:Label runat="server" ID="labelCityState" />
</div>
<asp:GridView runat="server" ID="gridViewRecordData">
<!--define columns & footer calculations here -->
</asp:GridView>
<hr/>
</ItemTemplate>
</asp:Repeater>
You can use the same ItemTemplate if you chose a ListView
Repeated is the best control. but in repeater you need to write code for Paging, Sorting...etc functiontly.
If you don't want to code for paging, sorting then go for GridView.
Try a ListView control. It lets you use templates to define how records, groups of records, etc. show up. For example you could define a template for your customer contact info, then a template for your records and other data.
You can accomplish this easily with a ListView. This article has a display of product information that's a lot like your layout -- horizontal lines between repeated sections.
I also like Scott Gu's tutorial, though the data layout (catalog images) is a little different from yours. Still, there's some good screenshots, and it also demos a Linq to SQL data source, which is a popular choice.
So I am using a Repeater inside a form to display a list of questions that are retrieved from a database.
Each Question allows the end user to select Yes or No and add some additional Text like this.
<ItemTemplate>
<asp:Panel runat="server">
<asp:RadioButtonList RepeatDirection="Horizontal" CssClass="YesNo" ID="YesNo" runat="server">
<asp:ListItem Value="Yes" Text="Yes" />
<asp:ListItem Value="No" Text="No" />
</asp:RadioButtonList>
</asp:panel>
<asp:Panel runat="server" CssClass="MoreInfo">
<asp:TextBox ID="TextBox1" TextMode="MultiLine" Height="70px" Rows="10" Columns="25" Wrap="true" runat="server" CssClass="MoreInfoText"></asp:TextBox>
</asp:Panel>
</ItemTemplate>
The repeater is databound to a datatable in the PageLoad event.
One on the fields in the datatable is the Question's number.
So when the data is posted how can I tell which question # each answer (Yes or No and additional Text) is refering to?
If I were generating the HTML by hand instead of using a Server Control I could just make the name of the html element that will be posting data like
name=variableHoldingQuestionNumber + YesNo
name=variableHoldingQuestionNumber + AdditionalComments
But I can't seem to use a variable when setting the Name attribute inside a Repeater Item.
Is abandoning the Server Control and writing the HTML myself my only solution.
Bind the questions number to a hidden field and when the save comes back, grab that hidden field back off and take the number out of it. Then you know which question you are looking at.
Put a break point on page load and do a postback. Take a deep look at Request.Form key/value pair collection. Everything from the post will be in there, with predictable labels/indexs.
In Insert Mode I want to show one kind of Template and Edit Mode I want to show another Kind of Template in Devexpress Control in C#.NET
This can be implemented using the following approach:
You should define the EditFormTemplate so that it contains a different set of editors for the Insert and Edit functionality. Handle the HtmlRowCreated event to hide non required editors based on the ASPxGridView's IsNewRowEditing property value.
Check out the sample project on this issue which demonstrates the solution based on user controls and binding expressions. In this solution, the EditForm template contains two user controls with the Visible property bound to the ASPxGridView.IsNewRowEditing property:
[HTML]
<uc1:Edit id="Edit1" runat="server" Visible="<%# !Container.Grid.IsNewRowEditing %>"></uc1:Edit>
<uc2:Insert id="Insert1" runat="server" Visible="<%# Container.Grid.IsNewRowEditing %>"></uc2:Insert>
Btw, this issue might also be helpful. If you need more help, please contact the DevExpress support team here.
Use an ASP template field and individual item templates inside your gridview
<asp:TemplateField id="test" runat="server">
<ItemTemplate>
<ItemTemplate>
test
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox Text="test" runat="server"/>
</EditItemTemplate>
</ItemTemplate>
</asp:TemplateField>
I did the above from memory. Heres a link to an example i found as well:
http://programming.top54u.com/post/ASP-Net-GridView-Edit-ItemTemplate-Mode.aspx