how to get top record from datalist - c#

how to get top of record by name in datalist..
<asp:DataList ID="dlOtherTrends" runat="server" OnItemDataBound="dlOtherTrends_OnItemDataBound">
<ItemTemplate>
<li><img id="imgPost" runat="server" width="70">
<span><asp:Label ID="lblPostName" runat="server"></asp:Label></span></li>
</ItemTemplate>
</asp:DataList>
now this is the list page..
<asp:DataList ID="dlPost" runat="server" OnItemDataBound="dlPost_OnItemDataBound">
<ItemTemplate>
<article>
<h1><asp:Label ID="lblPostName" runat="server" Text="Label"></asp:Label></h1><a name="<%# Eval("NAME") %>"></a>
<span class="posted">Posted on <asp:Label ID="lblPostDate" runat="server" Text="Label"></asp:Label> by Editor</span>
<p><img id="imgPost" runat="server" width="540"></p>
<p><div id="DivDescr" runat="server"></div></p>
<p> </p>
<!-- AddThis Button BEGIN -->
<div class="addthis_toolbox addthis_default_style ">
<a class="addthis_button_facebook_like"<%="fb:like:layout"%>="button_count"></a>
<a class="addthis_button_tweet"></a>
<a class="addthis_button_google_plusone"<%="g:plusone:size"%>="medium"></a>
<a class="addthis_counter addthis_pill_style"></a>
</div>
<script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#pubid=xa-4fc6ff7e30646c29"></script>
<!-- AddThis Button END -->
</article>
</ItemTemplate>
</asp:DataList>
by clicking of imgPost and lblPostName i need the same record in second one....the problem is all the records are coming in same page but i want to show selected one first

select top name from urdataTable desc
this will do if you are working with sql server

Related

How to use radio button with dynamic list view?

I am trying to make an online test system, where questions and options are added from database to list view. plz tell me how can i use radio button to check if question was correct or not.
this is the code i am using:-
<asp:listview ID="Listview1" runat="server">
<LayoutTemplate>
<ul class="row" style="list-style:none;">
<asp:PlaceHolder ID="itemPlaceholder" runat="server">
</asp:PlaceHolder>
</ul>
</LayoutTemplate>
<ItemTemplate>
<li>
<div class="row1">
Q. <%#Eval("question") %>><br />
<asp:RadioButton ID="RadioButton1 runat="server" /><%#Eval("op1") %>>
<br />
<asp:RadioButton ID="RadioButton2" runat="server" /><%#Eval("op2") %>>
<br />
<asp:RadioButton ID="RadioButton3" runat="server" /><%#Eval("op3") %>>
<br />
<asp:RadioButton ID="RadioButton4" runat="server" /><%#Eval("op4") %>>
</div>
</li>
</ItemTemplate>
</asp:listview>
Since you are loading the options dinamically, you have to get the values using Request["RadioButton1"] for example, after the postback

In asp.net C# webform Have a list view with one button after binding it convert to many buttons dynamically want to highlight Clicked button

I have Button btnTags in List View When ListView is Bind then its has Buttons Like
btnTags1 btnTags2 btnTags3 btnTags4 btnTags5 btnTags6
When Clicked on btnTags2
the Color of btnTags2 Should Change
When Clicked on A3
the btnTags2 color should rest to default
and A3 should be highlighted
<asp:ListView ID="ListViewCompanyServicesList" runat="server" ItemPlaceholderID="itemPlaceHolder" OnItemCommand="ListViewCompanyServicesList_ItemCommand">
<LayoutTemplate>
<div id="itemPlaceHolder" runat="server" style="margin-bottom: 0px;">
</div>
</LayoutTemplate>
<ItemTemplate>
<asp:LinkButton ID="btnTags" runat="server" Text='<%# Eval("Service") %>' CommandName="SelectService" CommandArgument='<%# Eval("ServiceId") %>' CssClass="label label-default" Style="display: inline-block" OnClick="btnTags_Click" />
</ItemTemplate>
<EmptyDataTemplate>
<div class="promote_contentBox2">
<p class="well" style="font-size: 80%;">No record Found</p>
</div>
</EmptyDataTemplate>
</asp:ListView>

Multilingual pages and dynamic multilingual content

I am creating a web app that has multilingual pages in dynamic multilingual contents or pages as well. The problem is actually with multilingual contents. When I use visible prop or the repeater component then it works well, but the problem when writes a lot of code, I think there must be a simpler way for this?
<!--Turkish-->
<asp:ListView runat="server" ID="lvListAllProdsTr">
<ItemTemplate>
<div class="gallery_box">
<a rel="lightbox[portfolio]" href='<%# Eval("ImgUrl") %>' title='<%# Eval("ProdNameTr") %>'>
<img src='<%# Eval("ImgUrl") %>' />
</a>
<h3>
<a href="#">
<%# Eval("ProdNameTr") %>
</a>
</h3>
<a href="#" class="more">
<asp:Literal ID="ltrDetayTr" Text="Detay" runat="server" /></a>
<div class="cleaner">
</div>
</div>
</ItemTemplate>
</asp:ListView>
<asp:DataPager ID="dpTr" runat="server" PagedControlID="lvListAllProdsTr" PageSize="10">
<Fields>
<asp:NumericPagerField />
</Fields>
</asp:DataPager>
<!--Turkish-->
<!--Russian-->
<asp:ListView runat="server" ID="lvListAllProdsRu">
<ItemTemplate>
<div class="gallery_box">
<a rel="lightbox[portfolio]" href='<%# Eval("ImgUrl") %>' title='<%# Eval("ProdNameRu") %>'>
<img src='<%# Eval("ImgUrl") %>' />
</a>
<h3>
<a href="#">
<%# Eval("ProdNameRu") %>
</a>
</h3>
<a href="#" class="more">
<asp:Literal ID="ltrDetayTr" Text="Detay" runat="server" /></a>
<div class="cleaner">
</div>
</div>
</ItemTemplate>
</asp:ListView>
<asp:DataPager ID="dpRu" runat="server" PagedControlID="lvListAllProdsRu" PageSize="10">
<Fields>
<asp:NumericPagerField />
</Fields>
</asp:DataPager>
<!--Russian-->
instead of Eval("ProdNameTr") how about calling a method for example :
GetProductName(Container.DataItem)
inside this method you read the current locale (if you know by then from the culture or something) and return the appropriate value

ASP.NET outputting <br> tags?

I'm working on a website built in .net and its outputting linbreaks after each span for some reason. The code thats outputting the line breaks is
<asp:DataList ID="DL_Items" runat="server" DataKeyField="ProductID" oneditcommand="DL_Items_EditCommand"
oncancelcommand="DL_Items_CancelCommand"
onupdatecommand="DL_Items_UpdateCommand"
onitemcommand="DL_Items_ItemCommand"
onitemdatabound="DL_Items_ItemDataBound"
ondeletecommand="DL_Items_DeleteCommand" RepeatLayout="Flow">
<ItemTemplate>
I've tried looking around google for better solutions to this and all I could find was a way to generate the code in a table which i do not want. Is there a reason why the above code is generating line breaks, <br>
Compete itemtemplate
<ItemTemplate>
<div class="EC_Item_Left_Panel">
<ul class="EC_Item_Left_UL">
<li>
<asp:Image ID="IM_PIC" runat="server" ImageUrl='<%# Eval("path") %>' /></li>
<li>
<asp:LinkButton ID="BT_Edit" CssClass="ecom_edit_tbn" CommandName="Edit" runat="server">Edit Item</asp:LinkButton></li>
<li class="deleteRow">
<asp:LinkButton ID="BT_Delete" ToolTip='<%# Eval("ProductName") %>' runat="server" CssClass="deleteButton ecom_remove_tbn" Text="Delete" ForeColor="Red"></asp:LinkButton>
<asp:Button ID="deleteCommand" runat="server" CausesValidation="false" CommandName="Delete" CssClass="deleteCommand" style="display:none" />
</li>
<%--<asp:LinkButton CssClass="ecom_remove_tbn" ID="BT_Remove" CommandName="Delete" runat="server">Remove</asp:LinkButton>--%>
<li><asp:LinkButton CssClass="ecom_link_tbn" ID="BT_Link" runat="server" CommandName="linkproduct">Linked Items</asp:LinkButton></li>
</ul>
</div>
<div>
<div class="Item_Right_Panel">
<ul class="EC_Item_Top_UL">
<li><label>ProductID </label><span><%#Eval("ProductID")%></span></li>
<li><label>Enabled </label><span><%#Eval("Enabled")%></span></li>
<li><label>Title </label><asp:Label ID="LB_ProductTitle" runat="server" Text='<%#Eval("ProductName")%>'></asp:Label></li>
<li><label>Product Code </label><span><%#Eval("ProductCode")%></span></li>
<li><label>Category </label><span><%#Eval("Category")%></span></li>
<%--Callum--%>
<li><label>Price</label><span><%#Eval("Sale_Price")%></span></li>
<li><label>Subcategory</label><span><%#Eval("Subcat")%></span></li>
<li><label>Designer</label><span><%#Eval("DesignerName")%></span></li>
<li><label>Range</label><span><%#Eval("Range")%></span></li>
<li><label>Height</label></li>
<li><label>Length</label></li>
<li><label>Width</label></li>
<li><label>Description </label><span><%#Eval("Description")%></span></li>
</ul>
<ul class="EC_Item_Bottom_UL">
<li><label>KeyFieldName </label><span><%#Eval("KeyFieldName")%></span></li>
<li><label>ItemField1Name </label><span><%#Eval("ItemField1Name")%></span></li>
<li><label>ItemField2Name </label><span><%#Eval("ItemField2Name")%></span></li>
<li><label>ItemField3Name </label><span><%#Eval("ItemField3Name")%></span></li>
<li><label>ItemField3Name </label><span><%#Eval("ItemField3Name")%></span></li>
<li><label>Include File </label><span> <%# IncludeTitle(DataBinder.Eval(Container.DataItem, "include"))%> </span></li>
</ul>
</div>
</div>
</ItemTemplate>
The DataList creates the br's(See documentation of Flow layout at http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.repeatlayout%28v=VS.100%29.aspx).
If you don't want br's or any extra markup between elements, I'd suggest you to use a Repeater instead.

ListView Coding

How do i code the "View Details" portion of my ListView to hyperlink it to the product details page? My product catalog is displayed as follows:
ListView codes
<asp:ListView runat="server" ID="listView" GroupItemCount="3"
DataSourceID="AccessDataSource1">
<LayoutTemplate>
<div style="height: 966px;">
<div style="width: 771px;">
<asp:PlaceHolder runat="server" ID="groupPlaceHolder" />
<asp:DataPager runat="server" ID="dpMyDatePager" PageSize="9"
PagedControlID="listView">
<Fields>
<asp:NextPreviousPagerField ButtonType="Button" ShowLastPageButton="True"
ShowFirstPageButton="True" />
<asp:NumericPagerField />
</Fields>
</asp:DataPager>
</div>
</LayoutTemplate>
<GroupTemplate>
<div style="clear: both;">
<asp:PlaceHolder runat="server" ID="itemPlaceHolder" />
</div>
</GroupTemplate>
<ItemTemplate>
<div class="productItem">
<div>
<img src='<%# Eval("ProductUrl") %>' >
</div>
<div class="catalog-price">
<br />
<%# Eval("ProductBrand") %>
<%# Eval("ProductModel") %></div>
<div class="catalog-price2">
<b>
Our Price: S$<%# Eval("NormalPrice") %></div>
</b><br />
<div class="cell1">
Add to cart</div>
<div class="cell2">
View details</div>
</div>
</ItemTemplate>
You have to pass the id of Selected Product to view the details of Selected Product.
Your ViewDetails button code should be like...
<asp:HyperLink ID="HypViewDetails" ImageUrl="~/Images/viewDetails.png"
NavigateUrl='<%#Eval("ProductId", "ProductDetails.aspx?cid={0}")%>'
runat="server"></asp:HyperLink>
Put the view details div in a hyperlink, coded with the model id?

Categories

Resources