I have an application with star rating.
Star rating inside repeater.
<asp:Repeater ID="reptweet" runat="server" onitemcommand="reptweet_ItemCommand">
<ItemTemplate>
<div class="divtweet">
<span class="box_imag">
<asp:Image ID="ScreenImage" runat="server" ImageUrl='<%#DataBinder.Eval(Container.DataItem,"ImageUrl")%>' height="50" width="50" /></span>
<span class="box_cont">
<div><strong> <a rel="external" href='http://twitter.com/<%#DataBinder.Eval(Container.DataItem,"ScreenName")%>' target="_blank">
<asp:Label ID="lblScreenName" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "ScreenName")%>'></asp:Label></a></strong>
<asp:Label ID="lblText" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "Text")%>'></asp:Label>
</div>
<div class="meta"><asp:Label ID="lblDate" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "Date")%>'></asp:Label></div>
</span>
<asp:UpdatePanel ID="updtpnlTweet" runat="server">
<ContentTemplate>
<cc1:Rating ID="rateTweet" runat="server"
CurrentRating="3"
MaxRating = "5"
StarCssClass="ratingStar"
EmptyStarCssClass="empatyStarRating"
FilledStarCssClass="filledStarRating"
WaitingStarCssClass="savedStarRating"
OnChanged="rateTweet_Changed"
>
</cc1:Rating>
</ContentTemplate>
</asp:UpdatePanel>
<asp:DropDownList ID="DropDownList1" runat="server" Width="100px" CssClass="dropdowntweet" DataSourceID="SqlDataSource1" DataTextField="CategoryName" DataValueField="CategoryId" >
</asp:DropDownList>
</div>
</ItemTemplate>
</asp:Repeater>
Through this code its shows multiple rows and i want sort this repeater content on the basis of star rating.
So can i get the value of star according per row.
Or is there any other way for star rating.
If you are looking for a setup of repeating values broken up into rows a grid view control might make things much easier. A repeater isn't really designed for the concept of date being broken up into logical "rows", it's really made so you can customize the format of your repeating data. Trying to iterate through a repeater is quite a pain in the neck.
With the grid view iterating through your rows is as simple as:
foreach (GridViewRow ratingRow in RatingGrid.Rows)
{
Rating ratingControl;
int rating;
ratingControl = (Rating)(ratingRow.FindControl("rateTweet"));
rating = ratingControl.CurrentRating;
}
Good grid view examples here
Related
Good day everyone,
This is my first post in here and I would like to thank you all for the great efforts in this forum by which I have already gaind a lot of skills.
I have a smalle issue with two nested repeaters. Basically, I have a dropdownlist in a child repeater which contains rating values and every time the dropdownlist is changed in the child repeater the new percentange is calculated and presented in a label in the parent repeater. This will cause full postback which is really frustrating when going through too many dropdownlists. My question is how to reflect the new calculated percentange in the label without postback. I have tried to use AsyncPostBackTriggers but no luck. Any suggestions would be appreiciated
<asp:Repeater ID="rptParent" runat="server">
<ItemTemplate>
<asp:Label ID="lblAvg" runat="server" Text='<%# Eval("TrialScore")%>'></asp:Label>
<asp:Repeater ID="rptChild" runat="server">
<ItemTemplate>
<asp:DropDownList ID="lstRate" runat="server" OnSelectedIndexChanged="lstRate_SelectedIndexChanged" />
</ItemTemplate>
</asp:Repeater>
</ItemTemplate>
</asp:Repeater>
Wrap your aspx mark up inside update panel like this.
<asp:UpdatePanel runat="sever" ID="upParentChild" >
<ContentTemplate>
<asp:Repeater ID="rptParent" runat="server">
<ItemTemplate>
<asp:Label ID="lblAvg" runat="server" Text='<%# Eval("TrialScore")%>'></asp:Label>
<asp:Repeater ID="rptChild" runat="server">
<ItemTemplate>
<asp:DropDownList ID="lstRate" runat="server" OnSelectedIndexChanged="lstRate_SelectedIndexChanged" />
</ItemTemplate>
</asp:Repeater>
</ItemTemplate>
</asp:Repeater>
</ContentTemplate>
</asp:UpdatePanel>
This will make sure that only controls inside update panel are posted back and not the whole page.
I am looking for an alternative where user doesnt has to wait for postback in an asp.net page.
My situation :
I have several drop down lists on my asp.net page (11 infact) and I have a checkbox. 2 drop downs are cascading. i.e. selecting 1st drop down changes the 2nd drop down contents. I have a new option in some of the dropdowns (6 drop downs). If user chooses this option then a text box shows up with a "Add" button. Adding text to that text box and hitting "Add" adds the new value to the drop down and disappears this textbox and the button. So is it possible for using a non postback option but have the same situation going on? User does not like that the page postbacks 11 times. What is my alternative? If you need more information, please ask. Thanks
EDIT:
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:DropDownList ID="ddlCustomerContact" runat="server" DataTextField="FullName" DataValueField="Customers_SourceIDfk2" AutoPostBack="true" TabIndex="1" />
</ContentTemplate>
</asp:UpdatePanel>
Protected Sub ddlCustomerContact_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ddlCustomerContact.SelectedIndexChanged
If ddlCustomerContact.SelectedIndex = 1 Then
divAddNewCustomerContact.Visible = True
Else
divAddNewCustomerContact.Visible = False
End If
End Sub
Your only real option if you don't want standard postbacks would be AJAX. There are numerous frameworks available, so you can use the Microsoft framework (bundled in 3.5+) or jQuery (also bundled in VS 2010+, I believe).
There are other frameworks available, but those two are going to be the most tightly integrated. Other frameworks will require a little more work to implement.
This is how I use an update panel for a widget that I created.
<asp:DropDownList ID="ddlPayrollStores" runat="server" OnSelectedIndexChanged="ddlPayrollStores_SelectedIndexChanged" AutoPostBack="true">
</asp:DropDownList>
<asp:UpdatePanel ID="UpdatePanelPayroll" runat="server">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="ddlPayrollStores" EventName="SelectedIndexChanged"></asp:AsyncPostBackTrigger>
</Triggers>
<ContentTemplate>
<div class="dragbox-content">
<asp:Label ID="lblLabelHours" runat="server" Text="Reg Hours: " Width="350px"></asp:Label>
<asp:Label ID="lblTotalHours" runat="server" Text=""></asp:Label>
<br />
<br />
<asp:Label ID="lblLabelOverTime" runat="server" Text="Total Overtime Hours: " Width="350px"></asp:Label>
<asp:Label ID="lblTotalOvertime" runat="server" Text=""></asp:Label>
<br />
<br />
<asp:Label ID="lblLabelHoliday" runat="server" Text="Total Holiday: " Width="350px"></asp:Label>
<asp:Label ID="lblTotalHoliday" runat="server" Text=""></asp:Label>
<br />
<br />
<asp:Label ID="lblLabelVacation" runat="server" Text="Total Vacation: " Width="350px"></asp:Label>
<asp:Label ID="lblTotalVacation" runat="server" Text=""></asp:Label>
<br />
<br />
<asp:Label ID="lbllableTotalHours" runat="server" Text="Total Hours: " Width="350px"></asp:Label>
<asp:Label ID="lblTotalStoreHours" runat="server" Text=""></asp:Label>
<br />
<br />
<asp:Label ID="lblLabelPay" runat="server" Text="Total Pay: " Width="350px"></asp:Label>
<asp:Label ID="lblTotalPay" runat="server" Text=""></asp:Label>
<br />
<br />
<div style="align-content: center">
<asp:LinkButton ID="lbDetailed" runat="server" Text="Detailed Report" PostBackUrl="~/Reporting/Payroll/StorePayroll.aspx"></asp:LinkButton>
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
This is for a payroll widget that shows the store's total payroll. So when I select which store I want to see with the drop down, the update panel will post back without posting back the entire page. In my case, it will just display numbers as labels. Hopefully this leads you in the right direction and possibly clears it up a bit.
datalist is as follows:
<asp:DataList ID="DataListComments" runat="server"
DataKeyField="Pk_Comment_Id" DataSourceID="SqlDataSourceComments" Width="100%">
<HeaderStyle BackColor="Gray" HorizontalAlign="Center" />
<HeaderTemplate>
<asp:Label ID="Label1" runat="server" BackColor="Gray"
ForeColor="White" Text="Comments" Width="100%" />
</HeaderTemplate>
<ItemTemplate>
<div class="CommentBox">
<div class="CommentImage">
<asp:HyperLink ID="HyperLink1" runat="server"
NavigateUrl='<%# "Profile.aspx?uid=" + Eval("fk_User_Id")%>'>
<asp:Image ID="imgUserC" runat="server"
ImageUrl='<%# Eval("Profile_Pic") %>' CssClass="scaling-image" />
</asp:HyperLink>
</div>
<div class="CommentInfo">
<div class="CommentUsername">
<asp:HyperLink ID="linkUserProfile" runat="server"
NavigateUrl='<%# "Profile.aspx?uid=" + Eval("fk_User_Id")%>'><%# Eval("Username") %></asp:HyperLink>
</div>
<div class="CommentDate">(<%# Eval("Date") %>)</div>
<div class="CommentDescription"><%# Eval("Description") %></div>
</div>
</div>
</ItemTemplate>
</asp:DataList>
Now, suppose there are 24 entries for [comments] in the database... I want to show only 3 here... And add a load more button in the footer template, on clicking this load more 5 more comments should be displayed..
If there is a possible solution to this with ajax, i wouldn't have any problem with that. I just need a working solution to this, as I am clueless on how to achieve this.
It's quite complicated when you are using runat server controls like gridview and datalist etc.
To achieve your goal:
You need to create web service
Get records from data base by using the service and JavaScript
Append the result at bottom by using JavaScript
These are things you need to do, and many other problem will start when you will work with server controls.
I'm just wondering if there's a way to add a new checkbox item to an existing asp:checkboxlist control, when another checkbox is checked, without having to do a full postback of the page. Whether it's with javascript, jquery, ajax. Just wondering how (if at all) I can do something like this.
I've been doing some research and it appears I can do a partial postback using an asp:UpdatePanel. I've never used one of these before. Does anyone have an example of how they can be used? Here's what I have, but it's still doing a full postback
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<tr>
<td width="50%">
<asp:CheckBox runat="server" ID="chkEnglish" Font-Bold="true" TextAlign="Right" Text=" English" />
</td>
<asp:Panel runat="server" ID="pnlTopLanguages">
<td rowspan="3" valign="top">
<asp:CheckBoxList ID="chkTopLanguages" CssClass="cb chkTopLangs" TextAlign="Right" runat="server" />
<asp:TextBox runat="server" ID="txtOtherLanguages" onkeyup="SetButtonStatus(this)" onclick="return clearLanguageSearchText()" Text="Other Languages..."></asp:TextBox>
<asp:Button runat="server" ID="btnAddLang" Text="Add" OnClientClick="return CopyOtherLangs()" Enabled="false" /><br /><br />
<asp:CheckBox runat="server" ID="chkManyOtherLanguages" CssClass="cb" Font-Bold="true" Text="Many other languages" />
<cc3:AutoCompleteExtender ID="aceSearch" runat="server" MinimumPrefixLength="1" TargetControlID="txtOtherLanguages"
ServicePath="~/controls/wsCommunity.asmx" ServiceMethod="GetLanguageCompletionList"></cc3:AutoCompleteExtender>
</td>
</asp:Panel>
</tr>
</ContentTemplate>
</asp:UpdatePanel>
Building off Adils answer...to add a checkbox on check of another one, you can use:
$(".classOfCheckboxList").change(function() {
$(this).append("<input type='checkbox' id='newbox' class='currentclass' value='someval' />");
});
As Adil said, this new dynamically added box wont be accessible in the code-behind.
i am trying to display a list of products
i am using a repeater, the repeater is working perfectly but its not showing the information as i want. i want to display in columns each colums has 6 products and it repeat depending on the number of products.
this is a sample of the code that i am using
page.aspx.cs
AllProducts = pm.GetProductOfMerchantByCat(ID, catid);
ProductRepeater.DataSource = AllProducts;
ProductRepeater.DataBind();
page.aspx
<asp:Repeater id="ProductRepeater" runat="server" Visible="true">
<HeaderTemplate>
<ul id="ProductsContent" class="jcarousel-skin-tango">
</HeaderTemplate>
<ItemTemplate>
<li>
<div class="product">
<h4><%# DataBinder.Eval(Container.DataItem, "Name")%></h4>
<asp:HiddenField ID="HiddenFeildQuantity"
Value='<%# Eval("Quantity") %>'
runat="server" />
</div>
</li>
</ItemTemplate>
<FooterTemplate>
</ul>
</FooterTemplate>
</asp:Repeater>
any help would be great .. thank you
Hey as per my Understanding you need to use DataList Instead of Repater.
Check This property
RepeatColumns
RepeatDirection
MSDN : http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.datalist.aspx