Webcenter Sites - How I can order a assetset list of assets by attribute value? - webcenter

I have a Asset (Modal_MKT) with a list of attributes. One of these attributes is order (int value). I want get the list of Modal_MKT elements created in WCS ordered by order field.
I let my code, this loops across all the correct modals, but final list isn't ordered by my "order" field.
<%-- Creamos el objeto donde añadir los criterios de búsquedas --%>
<searchstate:create name="ssModales"/>
<%-- Si estamos en la versión móvil, sólo nos interesan las modales creadas para móvil, sino las de escritorio --%>
<ics:if condition='<%="Touch".equalsIgnoreCase(ics.GetVar("outputdevice"))%>'>
<ics:then>
<searchstate:addsimplelikeconstraint name="ssModales" typename="Content_Attribute" attribute="showMobile" value="Si" immediateonly="true"/>
</ics:then>
<ics:else>
<searchstate:addsimplelikeconstraint name="ssModales" typename="Content_Attribute" attribute="showDesktop" value="Si" immediateonly="true"/>
</ics:else>
</ics:if>
<%-- Cargamos conjunto de assets de las modales del sistema --%>
<assetset:setsearchedassets name="asModales" constraint="ssModales" assettypes="Modal_MKT" site='<%= ics.GetVar("siteId") %>'/>
<%-- Obtenemos los valores que queramos ordenados como queramos --%>
<assetset:getmultiplevalues name="asModales" prefix="vList" immediateonly="true" byasset="true">
<assetset:sortlistentry attributetypename="Content_Attribute" attributename="order" direction="descending" />
<assetset:sortlistentry attributetypename="Content_Attribute" attributename="modalTitle" direction="none" />
<assetset:sortlistentry attributetypename="Content_Attribute" attributename="modalStartDate" direction="none" />
<assetset:sortlistentry attributetypename="Content_Attribute" attributename="modalEndDate" direction="none" />
<assetset:sortlistentry attributetypename="Content_Attribute" attributename="showMobile" direction="none" />
<assetset:sortlistentry attributetypename="Content_Attribute" attributename="showDesktop" direction="none" />
</assetset:getmultiplevalues>
<%-- Pasamos el conjunto de assets a una lista y la recorremos --%>
<assetset:getassetlist name="asModales" listvarname="aslist"/>
<ics:listloop listname="aslist">
<ics:listget listname="aslist" fieldname="assetid" output="theid"/>
<ics:listget listname='<%="vList:"+ics.GetVar("theid")+":modalTitle"%>' fieldname="value" output="title"/>
<ics:listget listname='<%="vList:"+ics.GetVar("theid")+":order"%>' fieldname="value" output="order" />
<ics:listget listname='<%="vList:"+ics.GetVar("theid")+":modalStartDate"%>' fieldname="value" output="modalStartDate" />
<ics:listget listname='<%="vList:"+ics.GetVar("theid")+":modalEndDate"%>' fieldname="value" output="modalEndDate" />
<ics:listget listname='<%="vList:"+ics.GetVar("theid")+":showMobile"%>' fieldname="value" output="showMobile" />
<ics:listget listname='<%="vList:"+ics.GetVar("theid")+":showDesktop"%>' fieldname="value" output="showDesktop" />
<br/>
<%= ics.GetVar("theid") %> -
<%= ics.GetVar("title") %> -
<%= ics.GetVar("modalStartDate") %> -
<%= ics.GetVar("modalEndDate") %> -
<%= ("Si".equals(ics.GetVar("showMobile")))? "Movil:Si" : "Movil:No" %> -
<%= ("Si".equals(ics.GetVar("showDesktop")))? "Desktop:Si" : "Desktop:No" %> -
<%= (Utilities.goodString(ics.GetVar("order")))? ics.GetVar("order") : "0" %>
</ics:listloop>
This list all assets from Modal_MKT content, but there isnt ordered by my attribute

Related

index Gridview Attribute onclic with button hidden

I need select row in gridview with a button hidden, but without postback because i need that stay on position clicked in gridview, this step i got it, but when i clicked on row capture index = 0, but when i click in button (no hidden in this time), capture correct index, how can I do this, thanks for your help or any idea.
my code is:
aspx:
<asp:UpdatePanel ID="UPGrvConfident" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<div class="table-responsive" id="gridDentalNetworkContainer" style="overflow: auto; height: 207px; cursor: pointer; padding: 0px">
<asp:GridView ID="gridDentalNetwork" EnableViewState="true" AllowSorting="false" runat="server" GridLines="None" Width="100%"
EmptyDataText="No hay elementos a mostrar." AutoGenerateColumns="false" ClientIDMode="Static"
DataKeyNames="numero" ShowHeaderWhenEmpty="true" HeaderStyle-HorizontalAlign="Center" HeaderStyle-BackColor="Gainsboro" HeaderStyle-BorderWidth="2px" RowStyle-BackColor="White"
RowStyle-BorderColor="White" RowStyle-Font-Size="Smaller" RowStyle-Font-Bold="false" CellPadding="3" CellSpacing="0">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:Button ID="btnSelect" runat="server" CommandName="Delete" CausesValidation="false" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Numero" ItemStyle-CssClass="Hides" HeaderStyle-CssClass="Hides" />
<asp:BoundField DataField="Nombre" HeaderText="Nombre" ItemStyle-CssClass="Hides" HeaderStyle-CssClass="Hides" />
<asp:BoundField DataField="Identificacion" HeaderText="Identificación" ItemStyle-Width="10%" HeaderStyle-Width="10%" />
<asp:BoundField DataField="Msg" HeaderText="Nombre">
<ItemStyle HorizontalAlign="Left" />
</asp:BoundField>
<asp:BoundField DataField="ApellidoPaterno" HeaderText="Primer Apellido" ItemStyle-CssClass="Hides" HeaderStyle-CssClass="Hides" />
<asp:BoundField DataField="ApellidoMaterno" HeaderText="Segundo Apellido" ItemStyle-CssClass="Hides" HeaderStyle-CssClass="Hides" />
<asp:BoundField DataField="Contrato" HeaderText="Contrato" />
<asp:BoundField DataField="contratocanal" HeaderText="Contratante" ItemStyle-Width="242px" HeaderStyle-Width="242px">
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:BoundField DataField="Titular" HeaderText="Usuario Principal">
<ItemStyle HorizontalAlign="Left" />
</asp:BoundField>
<asp:BoundField DataField="NroDoc" HeaderText="nro_row" ItemStyle-CssClass="Hides" HeaderStyle-CssClass="Hides" />
<asp:BoundField DataField="NroPariente" HeaderText="nro_pariente" ItemStyle-CssClass="Hides" HeaderStyle-CssClass="Hides" />
<asp:BoundField DataField="NroPol" HeaderText="nro_pol" ItemStyle-CssClass="Hides" HeaderStyle-CssClass="Hides" HeaderStyle-Width="5px" />
<asp:BoundField DataField="NroAseg" HeaderText="nro_aseg" ItemStyle-CssClass="Hides" HeaderStyle-CssClass="Hides" />
<asp:BoundField DataField="TxtRed" HeaderText="fec_nac" ItemStyle-CssClass="Hides" HeaderStyle-CssClass="Hides" />
<asp:BoundField DataField="Plan" HeaderText="Plan">
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:BoundField DataField="fec_alta" HeaderText="Fecha Ingreso" ItemStyle-Width="96px" HeaderStyle-Width="96px">
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
</Columns>
<AlternatingRowStyle BackColor="#f2f2f2" />
</asp:GridView>
</div>
</ContentTemplate>
</asp:UpdatePanel>
aspx.vb (code behind)
RowdataBound
Protected Sub gridDentalNetwork_OnRowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs) Handles gridDentalNetwork.RowDataBound
'e.Row.Cells(0).Style("display") = "none"
If e.Row.RowType = DataControlRowType.DataRow Then
e.Row.Attributes("onmouseover") = "this.style.cursor='hand';this.style.textDecoration='underline';"
e.Row.Attributes("onmouseout") = "this.style.textDecoration='none';"
Dim btnSelect As Button = TryCast(e.Row.FindControl("btnSelect"), Button)
btnSelect.CommandArgument = e.Row.RowIndex.ToString()
'e.Row.Attributes("onclick") = String.Format("document.getElementById('{0}').click();", btnSelect.ClientID)
e.Row.Attributes.Add("onclick", "document.getElementById('" & btnSelect.ClientID & "').value = '" & e.Row.RowIndex.ToString() & "'; alert(document.getElementById('" & btnSelect.ClientID & "').value); darClick();")
'e.Row.Attributes.Add("onclick", "var dato = document.getElementById('btnSelect').value; '<%Session['temp']='+ dato +';%>'; alert('<%=Session['temp']%>');")
'e.Row.Attributes("onclick") = String.Format("document.getElementById('{0}').click();", btnSelect.ClientID)
'e.Row.Attributes("onclick") = Page.ClientScript.GetPostBackClientHyperlink(gridDentalNetwork, "Select$" + e.Row.RowIndex.ToString())
'e.Row.Attributes.Add("onclick", String.Format("document.getElementById('{0}').click();", btnSelect.ClientID))
e.Row.ToolTip = "Clic para seleccionar"
End If
End Sub
Method: I am using RowDeleting for commandField.
Protected Sub gridDentalNetwork_RowDeleting(ByVal sender As Object, ByVal e As GridViewDeleteEventArgs) Handles gridDentalNetwork.RowDeleting
Dim ListBiored As List(Of MClienteSimple) = New List(Of MClienteSimple)
Dim grvfila As GridViewRow
Dim indexx As String = Session("index")
grvfila = gridDentalNetwork.Rows(e.RowIndex)
Dim lstClientesConf As New MClienteDentalNetwork
lstClientesConf = DirectCast(Session("ClientesConf"), List(Of MClienteDentalNetwork))(grvfila.DataItemIndex)
...etc..etc
End Sub

How to show records in GridView between two dates

I have a search button and two textboxes that function as a datetime picker. What can I do to show all the records in a specific date interval? I am new to programming.
<%# Page Title="Report" Language="VB" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeFile="Report.aspx.vb"
Inherits="Report" %>
<asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="MainContent">
<asp:GridView ID="gvItems" runat="server" AutoGenerateColumns ="false">
<Columns>
<asp:BoundField HeaderText="Part Number" DataField="Part_Number" readonly="true" ></asp:BoundField>
<asp:BoundField HeaderText="Last Inventory" DataField="Last_Inv" readonly="true" ></asp:BoundField>
<asp:BoundField HeaderText="Last Quantity" DataField="Last_Qty" readonly="true" ></asp:BoundField>
<asp:BoundField HeaderText="Inventory Today" DataField="Today_Inv" readonly="true" ></asp:BoundField>
<asp:BoundField HeaderText="Today's Quantity" DataField="Today_Qty" readonly="true" ></asp:BoundField>
</Columns>
</asp:GridView>
<br />
<br />
<div class ="container" >
<div class="input-group class col-sm-3 col-md-6">
<asp:Button ID="btnSearch" runat="server" Text="Search" />
<asp:TextBox ID="txtbxSearch1" runat="server" TextMode ="Date" Width="205px"></asp:TextBox>
<asp:TextBox ID="txtbxSearch2" runat="server" TextMode ="Date" Width="205px"></asp:TextBox>
</div> <br /> <br />
</div>
<br />
<br />
Imports System.Data
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
Dim ds As DataSet = New DataSet
ds.Tables.Add(New DataTable)
ds.Tables(0).Columns.AddRange(New DataColumn() {New DataColumn("Id", GetType(System.Int32)), New DataColumn("Name", GetType(System.String)), New DataColumn("DOB", GetType(DateTime))})
ds.Tables(0).Rows.Add(1, "John Hammond", "12/12/1996")
ds.Tables(0).Rows.Add(2, "Mudassar Khan", "11/16/1995")
ds.Tables(0).Rows.Add(3, "Suzanne Mathews", "10/20/1997")
ds.Tables(0).Rows.Add(4, "Robert Schidner", "09/22/1991")
Dim dt2 As DataTable = New DataTable
dt2 = ds.Tables(0).Select.Where(() => { }, ((Convert.ToDateTime(p("DOB")) >= Convert.ToDateTime("12/12/1996")) _
AndAlso (Convert.ToDateTime(p("DOB")) >= Convert.ToDateTime("12/12/1996")))).CopyToDataTable
GridView1.DataSource = dt2
GridView1.DataBind
End Sub
Also, this link below should get you going in the right direction.
https://forums.asp.net/t/2041882.aspx?GridView+Filter+between+2+dates

dataExporter cannot be rendered because of form needing

I am trying to add dataExporter component to my table.
First I had {Exporters} beside pagination facet , then after a lot of tries I got this error in the console
HTML nesting warning on closing changes: element update not explicitly closed
I solved it also but now there is nothing appears in the Exporter facet. I googled it and found that I need a form in my page because of this commandlink submit a form , so it needs a form.
My Question here is how to apply this example in my project.
Here is my code.
<ui:composition template="/template.xhtml">
<ui:define name="title">
<h:outputText value="#{bundle.ViewLfmTitle}"></h:outputText>
</ui:define>
<ui:define name="body">
<h:panelGroup id="messagePanel" layout="block">
<h:messages errorStyle="color: red" infoStyle="color: green"
layout="table" />
</h:panelGroup>
<p:dialog header="Add Task" widgetVar="dlg" position="center center"
onShow="PF('dlg').initPosition()" modal="true" closeOnEscape="true"
resizable="false">
<h:form>
<h:panelGrid columns="2">
<p:outputLabel value="#{bundle.CreateTaskLabel_name}" for="name" />
<p:inputText id="name"
value="#{ViewLfmJpaController.newTaskDTO.name}"
title="#{bundle.CreateTaskTitle_name}" />
<p:outputLabel value="#{bundle.CreateTaskLabel_durationPerMonth}"
for="durationPerMonth" />
<p:inputText id="durationPerMonth"
value="#{ViewLfmJpaController.newTaskDTO.duration}"
title="#{bundle.CreateTaskTitle_durationPerMonth}" />
<p:outputLabel value="#{bundle.CreateTaskLabel_startDate}"
for="startDate" />
<p:calendar id="startDate"
value="#{ViewLfmJpaController.newTaskDTO.startDate}"
title="#{bundle.CreateTaskTitle_startDate}" pattern="d MMM yyyy"
effect="fold">
<f:convertDateTime pattern="d MMM yyyy" />
</p:calendar>
<p:outputLabel value="#{bundle.CreateTaskLabel_endDate}"
for="endDate" />
<p:calendar id="endDate"
value="#{ViewLfmJpaController.newTaskDTO.endDate}"
title="#{bundle.CreateTaskTitle_endDate}" pattern="d MMM yyyy"
effect="fold">
<f:convertDateTime pattern="d MMM yyyy" />
</p:calendar>
<f:facet name="footer">
<p:commandButton value="Add"
actionListener="#{ViewLfmJpaController.addTask}" update="Matrix"
oncomplete="PF('dlg').hide()" />
</f:facet>
</h:panelGrid>
</h:form>
</p:dialog>
<p:dataTable id="Matrix" resizableColumns="true" scrollable="true"
scrollHeight="80%"
value="#{ViewLfmJpaController.selected.tasksDtoCollection}"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {Exporters}"
var="item" resizeMode="expand" paginator="true" rows="10"
style="margin-bottom:20px">
<f:facet name="header">
Logical Framewrok Matrix
</f:facet>
<f:facet name="{Exporters}">
<p:commandLink>
<p:graphicImage name="../resources/images/pdf.jpg" width="24" />
<p:dataExporter type="pdf" target="Matrix" fileName="lfm" />
</p:commandLink>
</f:facet>
<p:column headerText="Index" colspan="1">
<c:forEach var="i" begin="1" end="#{ViewLfmJpaController.listSize}">
<p:outputLabel value="#{i}"></p:outputLabel>
</c:forEach>
</p:column>
<p:column headerText="Task Title">
<p:outputLabel value="#{item.name}"></p:outputLabel>
</p:column>
<p:column headerText="Start Date" colspan="3">
<p:outputLabel value="#{item.formatedStartDate}"></p:outputLabel>
</p:column>
<p:column headerText="End Date" colspan="3">
<p:outputLabel value="#{item.formatedEndDate}"></p:outputLabel>
</p:column>
<c:forEach var="i" begin="1"
end="#{ViewLfmJpaController.numberOfMonths}">
<p:column headerText="m ${i}" colspan="1"></p:column>
</c:forEach>
<p:column headerText="Exptected Outcomes" colspan="4">
<ui:repeat value="#{item.tasksExpectedOutcomesCollection}" var="teo">
<li><h:outputText value="#{teo.expectation}">
</h:outputText></li>
</ui:repeat>
</p:column>
</p:dataTable>
<p:commandButton value="Add Task" oncomplete="PF('dlg').show()"></p:commandButton>
</ui:define>
</ui:composition>
I FOUND THE SOLUTION BY MYSELF.
First : You have to know that you cannot make nested forms in your page.
Second : you have to know that to submit <p:dialog> </p:dialog> or to use <h:commandLink> </h:commandLink> you need to use form.
So I had removed the form in the dialog component and add a general component contains dialog and dataTable together

Primefaces autocorrect option in selenium

Tried to select autocomplete textbox , i'm getting an exception.
WebElement autoOptions = driver.findElement(By.id("form:mat_input"));
autoOptions.sendKeys("b");
html snap :-
<p:autoComplete id="mat" required="true"
value="#{vCreateSupplyRequest._RequestMaterial}"
completeMethod="#{vCreateSupplyRequest.getMaterials}"
var="item" itemLabel="#{item.materialName}" itemValue="#{item}"
converter="materialConverter" forceSelection="true">
<p:ajax event="itemSelect"
listener="#{vCreateSupplyRequest.onMaterialSelection}"
update="mainGrid,mainGrid1" />
<p:column headerText="Material">
<h:outputText value="#{item.materialName}" />
</p:column>
<p:column headerText="Category">
<h:outputText value="#{item.materialCategory.categoryName}" />
</p:column>
</p:autoComplete>

Multipule information and Pics in multipule gridviews in ASP.NET using VB

I am trying to build a website and am running into a little trouble. My coding knowledge and savvy are armature at best,if you know a better way to do this than please by all means let me know.
On my Featured Bar page I have two gridviews set up. gvPicsRandomBar(For pictures only) and GVRandomBars(For Information only). Each has their own SQLDataSource. I have it set up to where GVRandomBars selects a "random" bar through the SQL TOP command. What I'm trying to do is get the gvPicsRandomBar to display a picture of the same "random" bar that is selected by GVRandomBars. Both gridviews are querying from the same table but with different SELECT statements as each gridview is concerned with different items in the same table row.
I thought I had somewhat accomplished this by reading the primary key from the GVRandomBars and placing that value in a Label(lblRandomBar) that I use as a control for gvPicsRandomBar to match up the correct pic to display in it's own gridview as they both query the same database, but I was wrong. Whenever I startup my website I get this error "Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index". I'm just not sure where to place this code i.e. (Event) lblRandomBar.Text = GVRandomBars.DataKeys(0).Value.ToString() so that I will not get the above error.
Seperate problems if by miracle I get it to work
One problem I have is that it appears that the value of the primary key is not passed on to lblRandomBar.text. I assume this is because I do not know where to correctly place the code lblRandomBar.Text = GVRandomBars.DataKeys(0).Value.ToString()The other problem I do have when I sometimes get it to work is that the picture displayed in gvPicsRandomBar is one step behind from when I click the search button. Example, I click search for city "Austin" in my dropdown list which could potentially give me a primary key value of 45. The picture for that primary key is not displayed until I click search for another city in the dropdown list and the page posts back to the server.
The value of the primary key is in lblRandomBar.text for the current bar displayed in the GVRandomBars but the picture of the bar associated with that recored does not appear in the gvPicsRandomBar until the search button is clicked and another "random" bar is displayed in the GVRandomBars. So I am looking at a picture in gvPicsRandomBar from the last bar that was brought up in GVRandomBars while another bars information is currently displayed in GVRadnomBars.
I am looking to have the same bar information and bar picture in both gridviews at the same time, and not one step behind like I have currently with the picture in gvPicsRandomBar. Any help would be greatly appreciated. Thanks.
ASP.NET HTML
<%# Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/Site.Master" CodeBehind="Random Bar.aspx.vb" Inherits="RGVHappyHour.Featured_Bar" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
<center><h2>Random Bar</h2></center>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<p>
<asp:GridView ID="gvPicsRandomBar" runat="server" AutoGenerateColumns="False" CellPadding="4" DataKeyNames="Number,Bar Name,Image" DataSourceID="SqlDataSourceRandomBarPics" ForeColor="#333333" GridLines="None" HorizontalAlign="Center" Width="548px">
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<Columns>
<asp:ImageField DataImageUrlField="Image" HeaderText="Image" NullDisplayText="No Picture">
</asp:ImageField>
</Columns>
<EditRowStyle BackColor="#999999" />
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#E9E7E2" />
<SortedAscendingHeaderStyle BackColor="#506C8C" />
<SortedDescendingCellStyle BackColor="#FFFDF8" />
<SortedDescendingHeaderStyle BackColor="#6F8DAE" />
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSourceRandomBarPics" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionStringBars %>" SelectCommand="SELECT * FROM [Bars] WHERE ([Number] = #Number)">
<SelectParameters>
<asp:ControlParameter ControlID="lblRandomBar" Name="Number" PropertyName="Text" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
</p>
<p>
<asp:GridView ID="GVRandomBars" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSourceRandomBar" Width="548px" CellPadding="4" ForeColor="#333333" GridLines="None" AllowPaging="True" DataKeyNames="Number" SelectedIndex="0">
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<Columns>
<asp:BoundField DataField="Bar_Name" HeaderText="Bar Name" SortExpression="Bar_Name" />
<asp:BoundField DataField="Addresss" HeaderText="Addresss" SortExpression="Addresss" />
<asp:BoundField DataField="Phone_Number" HeaderText="Phone Number" SortExpression="Phone_Number" />
<asp:BoundField DataField="Days" HeaderText="Days" SortExpression="Days" />
<asp:BoundField DataField="Happy_Hour" HeaderText="Happy Hour" SortExpression="Happy_Hour" />
</Columns>
<EditRowStyle BackColor="#999999" />
<FooterStyle BackColor="#5D7B9D" ForeColor="White" Font-Bold="True" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<RowStyle ForeColor="#333333" BackColor="#F7F6F3" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#E9E7E2" />
<SortedAscendingHeaderStyle BackColor="#506C8C" />
<SortedDescendingCellStyle BackColor="#FFFDF8" />
<SortedDescendingHeaderStyle BackColor="#6F8DAE" />
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSourceRandomBar" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionStringBars %>" SelectCommand="SELECT TOP (1) [Number], [Bar Name] AS Bar_Name, Addresss, [Phone Number] AS Phone_Number, Days, [Happy Hour] AS Happy_Hour, [Image] AS Image FROM Bars WHERE (City = #City) ORDER BY NEWID()">
<SelectParameters>
<asp:ControlParameter ControlID="ddlCity" Name="City" PropertyName="SelectedValue" />
</SelectParameters>
</asp:SqlDataSource>
<p>
<table class="style1" style="width: 100%">
<tr>
<td style="width: 220px; text-align: right;" class="style2">
<asp:Label ID="lblCity" runat="server" Text="City:" Font-Size="Large"
ForeColor="#47C2FF"></asp:Label>
</td>
<td style="width: 135px">
<asp:DropDownList ID="ddlCity" runat="server" DataSourceID="SqlDataSourceCity"
DataTextField="City" DataValueField="Number">
</asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSourceCity" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionStringBars %>" SelectCommand="SELECT * FROM [City] ORDER BY [City]"></asp:SqlDataSource>
</td>
<td style="width: 220px; position: relative; text-align: left; vertical-align: middle;">
<asp:Button ID="btnCitySearch" runat="server" Text="Search" />
</td>
</tr>
<tr>
<td style="width: 220px" class="style2" draggable="true">
<asp:Label ID="lblRandomBar" runat="server"></asp:Label>
</td>
<td style="width: 135px">
</td>
<td style="width: 220px">
</td>
</tr>
</table>
</p>
</asp:Content>
Code Behind Random Bar.aspx.vb
Public Class Featured_Bar
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub
Protected Sub btnCitySearch_Click(sender As Object, e As EventArgs) Handles btnCitySearch.Click
End Sub
Protected Sub GVRandomBars_SelectedIndexChanged(sender As Object, e As EventArgs) Handles GVRandomBars.SelectedIndexChanged
End Sub
Protected Sub btnCitySearch_DataBinding(sender As Object, e As EventArgs) Handles btnCitySearch.DataBinding
lblRandomBar.Text = GVRandomBars.DataKeys(0).Value.ToString()
End Sub
End Class