I am using the Telerik radlistview o display some results, i perform some grouping in my query and return a sorted and ordered resultset and set it to the datasource. For some reason (which i have been battling with all morning) the ListView re-orders the results by the ID column.
<telerik:RadListView runat="server" ID="rlThumbnailView" OnNeedDataSource="rlThumbnailView_NeedDataSource"
AllowPaging="true" PageSize="8" OnDataBound="rlThumbnailView_DataBound" OnItemDataBound="rlThumbnailView_ItemDataBound">
<LayoutTemplate>
<span style="vertical-align: top; position: relative; top: 4px">Displaying page
<%#Container.CurrentPageIndex + 1 %>
of
<%#Container.PageCount %></span> </span>
<br />
<div id="list">
<asp:Panel runat="server" ID="Panel1" Style="float: left; margin-left: 160px" Visible="<%#Container.PageCount > 1 %>">
<asp:Button runat="server" ID="PrevButton" CommandName="Page" CommandArgument="Prev"
Text="Prev Page" Enabled="<%#Container.CurrentPageIndex > 0 %>" />
<asp:Button runat="server" ID="NextButton" CommandName="Page" CommandArgument="Next"
Text="Next Page" Enabled="<%#Container.CurrentPageIndex < Container.PageCount - 1 %>" />
</asp:Panel>
<div>
<telerik:RadSlider runat="server" ID="RadSlider1" MaximumValue="3" MinimumValue="1"
Value="2" LiveDrag="false" SmallChange="1" AutoPostBack="true" OnValueChanged="RadSlider1_ValueChanged"
Width="150px" CausesValidation="false" />
</div>
<div style="clear: both;">
</div>
<asp:Panel ID="itemPlaceholder" runat="server">
</asp:Panel>
<div style="clear: both;">
</div>
</div>
</LayoutTemplate>
<ItemTemplate>
<div id="wrapper" runat="server" style="float: left; margin-top: 2px; margin-bottom: 2px;">
<telerik:RadBinaryImage ID="ThumnailImage1" runat="server" />
UPC:
<asp:Label ID="lblUPC" runat="server"></asp:Label><br />
Description:
<asp:Label ID="lblDescription" runat="server"></asp:Label>
<br />
<div id="dvCountries" runat="server">
Languages:</div>
Changes:<asp:Label ID="lblChanges" runat="server"></asp:Label>
<br />
Pack Format:<asp:Label ID="lblPackType" runat="server"></asp:Label>
<br />
Date Completed:<asp:Label ID="lblDateCompleted" runat="server"></asp:Label>
<br />
</div>
</div>
</ItemTemplate>
</telerik:RadListView>
I beleive this is based on the standard microsoft listview,
For anybody who faces the same issue, the answer appears here:
http://www.telerik.com/community/forums/aspnet-ajax/listview/listview-paging-and-sortorder.aspx
seems to be a bug with Telerik
Related
when I filter the Gridview I lose the Footable function.
Strange behavior, if I click on the filter button, filter by brand and select the Pireli option, then click the update button.
I lose the Footable function, but if I then click the Update button again leaving the filter as Pireli the Footable function returns!!!!!
Seeing is believing if you navigate to the following url www.tyrescanner.net
Enter registration WR08SZE
Enter postcode KA227PR
Sorry for the jumping around here.
If you click on the filer Brand option and select Pireli, the Gridview will lose the Footable function, but if you click again on the Update button the Footable function returns!!!!!!!!
<asp:Content ID="Content1" ContentPlaceHolderID="Header" runat="server">
<link href="https://cdnjs.cloudflare.com/ajax/libs/jquery-footable/0.1.0/css/footable.min.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery-footable/0.1.0/js/footable.min.js"></script>
<%--Resizing Gridview--%>
<script>
$(function () {
AttachjQueryFootableToTable();
});
function AttachjQueryFootableToTable() {
$('[id*=GridView1]').footable();
}
</script>
<script>
var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_endRequest(function () {
AttachjQueryFootableToTable();
});
</script>
<div class="row">
<div class="col-md-8 col-md-pull-0 ">
<asp:Label ID="lblRegText" runat="server" Text="Tyre Size: " Style="font-weight: 700; font-size: x-large" Visible="True"></asp:Label>
<asp:Label ID="lbltyresize" runat="server" Style="font-weight: 700; font-size: x-large" Visible="True"></asp:Label>
<a href="http://tyrescanner.net/pages/edit-tyre-size.aspx">
<asp:Label ID="lblEdit" runat="server" Text=" Edit" Style="font-size: large" Visible="True"></asp:Label>
</a>
</div>
</div>
<br />
<div class="row">
<div class="col-sm-4 col-md-4">
<div class="container">
<button type="button" class="btn btn-info" data-toggle="collapse" data-target="#demo"><span class="glyphicon glyphicon-filter">Filter</span></button>
<div id="demo" class="collapse">
<div class="row">
<div class="col-md-2 col-sm-2" style="width: 130px">
<h5><strong>Brand</strong></h5>
<asp:DropDownList ID="SRDDLBrand" runat="server" DataSourceID="SqlDataSourceBrand" DataTextField="TyreBrands" DataValueField="TyreBrands" Height="35px" Width="105px" AppendDataBoundItems="True">
<asp:ListItem Text="Select All" Value=" " />
</asp:DropDownList>
</div>
<div class="col-md-2 col-sm-2" style="width: 130px">
<h5><strong>Season</strong></h5>
<asp:DropDownList ID="SRDDLTyreType" runat="server" DataSourceID="SqlDataSourceTyreType" DataTextField="TyreType" DataValueField="TyreType" Height="35px" Width="105px" AppendDataBoundItems="True">
<asp:ListItem Text="Select All" Value=" " />
</asp:DropDownList>
</div>
<div class="col-md-2 col-sm-2" style="width: 130px">
<h5><strong>Fuel Efficiency</strong></h5>
<asp:DropDownList ID="SRDDLFuelCat" runat="server" DataSourceID="SqlDataSourceFuelCategory" DataTextField="TyreCategory" DataValueField="TyreCategory" Height="35px" Width="105px" AppendDataBoundItems="True">
<asp:ListItem Text="Select All" Value=" " />
</asp:DropDownList>
</div>
<div class="col-md-2 col-sm-2" style="width: 130px">
<h5><strong>Wet Grip</strong></h5>
<asp:DropDownList ID="SRDDLWetGrip" runat="server" DataSourceID="SqlDataSourceWetGrip" DataTextField="TyreCategory" DataValueField="TyreCategory" Height="35px" Width="105px" AppendDataBoundItems="True">
<asp:ListItem Text="Select All" Value=" " />
</asp:DropDownList>
</div>
<br />
<p></p>
<div class="col-md-2 col-sm-2">
<asp:Button ID="bntFilter" runat="server" OnClick="bntFIlter_Click" Text="Update Results" CssClass="btn Jumbt btn-custom" Style="color: white" role="button" Height="44px" />
</div>
</div>
</div>
</div>
</div>
</div>
<br />
<asp:UpdatePanel UpdateMode="Conditional" ID="UpdatePanel1" runat="server" ChildrenAsTriggers="true">
<ContentTemplate>
<asp:GridView ID="GridView1" CssClass="footable" runat="server" AutoGenerateColumns="False" Style="max-width: 130%" AutoPostback="Flash" DataKeyNames="ProductID,GarageID" DataSourceID="SqlDataSourceGridViewSearchResults"
EmptyDataText="Sorry we don’t have that tyre, please email us your requirements and we will add it to our Search engine – service#tyrescanner.net"
OnSelectedIndexChanging="GridView1_SelectedIndexChanging" OnSelectedIndexChanged="GridView1_SelectedIndexChanged" OnRowCommand="GridView1_RowCommand" OnRowDataBound="GridView1_RowDataBound" OnRowCreated="GridView1_RowCreated">
<Columns>
<%-- 0--%>
<asp:BoundField DataField="ProductID" HeaderText="ProductID" Visible="false" />
<%--1--%>
<asp:BoundField DataField="GarageID" HeaderText="GarageID" Visible="false" />
<%-- 2--%>
<asp:BoundField DataField="GarageTown" HeaderText="Garage Location"></asp:BoundField>
<%-- 3--%>
<asp:TemplateField HeaderText="Tyre Model">
<ItemTemplate>
<asp:Label ID="lblBrand" runat="server" Text='<%#Eval("Brand")+ " " + Eval("TyreModel")%>'></asp:Label>
<br />
<asp:Label ID="Label1" runat="server" Text="£" Height="16px" Width="4px" Font-Bold="True"></asp:Label>
<asp:Label ID="lblCurrency" runat="server" Font-Bold="True" Text='<%#Eval("ProductUnitSalePrice")%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<%-- 4--%>
<asp:BoundField DataField="TyreType" HeaderText="Tyre Type" />
<%-- 5 --%>
<asp:TemplateField HeaderText="Noise Level">
<ItemTemplate>
<asp:Label ID="lblNoiseEmission" runat="server" Text='<%#Eval("NoiseEmission")+ "dB"%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="FuelEfficiencyCategory" HeaderText="Fuel Efficiency" />
<%-- 6 --%>
<asp:BoundField DataField="WetGrip" HeaderText="Wet Grip" />
<%-- 7 --%>
<asp:TemplateField HeaderText="Select Quantity">
<ItemTemplate>
<asp:DropDownList ID="txtQuantity" runat="server" OnSelectedIndexChanged="txtQuantity_SelectedIndexChanged"
AutoPostBack="true" Width="55px" Height="32px" DataFormatString="{0:£ 0.0}" ForeColor="Black">
<asp:ListItem Text="0" Value=" " />
<asp:ListItem>1</asp:ListItem>
<asp:ListItem>2</asp:ListItem>
<asp:ListItem>3</asp:ListItem>
<asp:ListItem>4</asp:ListItem>
<asp:ListItem>5</asp:ListItem>
</asp:DropDownList>
<asp:Label ID="Errorlabel" runat="server" Text=""></asp:Label><p></p>
<asp:Label ID="LabelTotalPoundSign" runat="server" Font-Bold="true" Text="Total £" Height="16px" Width="4px"></asp:Label>
<asp:Label ID="lblTotal" runat="server" Font-Bold="true" Text="0.00" Width="30px"></asp:Label>
<asp:LinkButton runat="server" OnClick="btnOrder_Click" CommandName="Select" class="btn btn-custom btn-sm" Style="color: white">Order »</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
I have users whose group policies block Javascript; so any use of that is out of the question.
I have found a page that performs the function that I need:
Pure CSS Popup Box
However, the popup is triggered after an anchor is clicked.
My issue issue is that I want the popup to trigger on the event change in an asp:DropDownList. My intent is that if an item is not listed in the DDL, then the user will be able to select the first item "Not Listed". After this selection I need to have the popup open with elements that will allow them to add the items to the database which populates the DDL.
I have attempted to use the following in the DDL OnSelectedIndexChanged event:
Response.Redirect(HttpContext.Current.Request.Url.AbsoluteUri.ToString() + "#popup1");
This idea has failed. I believe it is because I have it inside an Update Panel. The setup is as follows:
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<!-- Main Wrapper -->
<div class="wrapper wrapper-style2">
<div class="container">
<!-- breadcrumbs -->
<br />
<div class="row 200%">
<div class="12u">
<!-- Content -->
<div id="maincontent" runat="server">
<asp:UpdatePanel ID="upInputarea" runat="server" UpdateMode="Conditional" AssociatedUpdatePanelID="updateProgress">
<ContentTemplate>
<%-- Equipment Data --%>
<section class="box post">
<h3 class="bold">Equipment Data</h3>
<asp:UpdatePanel ID="upEquipmentData" runat="server" UpdateMode="Conditional" AssociatedUpdatePanelID="updateProgress">
<ContentTemplate>
<div id="EquipmentDataDiv2" runat="server" style="float: left; border-left: 2px solid rgba(144, 144, 144, 0.25); margin-right: auto; margin-left: auto;">
<asp:Panel ID="Pnl1" runat="server" CssClass="inputSet2">
<span>Model:</span>
<asp:DropDownList ID="ddlEquipmentDataModel" runat="server" AppendDataBoundItems="true" AutoPostBack="false" CssClass="round-corners " DataSourceID="SqlModel" DataTextField="Model" DataValueField="ID" />
</asp:Panel>
<asp:Panel ID="Pnl2" runat="server" CssClass="inputSet2">
<span>Item:</span>
<asp:DropDownList ID="ddlEquipmentDataItem" runat="server" AppendDataBoundItems="true" AutoPostBack="true" CssClass="round-corners width1" DataSourceID="SqlItem" DataTextField="Component" DataValueField="ID" OnSelectedIndexChanged="ddl_SelectedIndexChanged" />
</asp:Panel>
<asp:Panel ID="Pnl5" runat="server" CssClass="inputSet2">
<span>S/N:</span>
<asp:TextBox ID="txtEquipmentDataSN" runat="server" CssClass="round-corners " />
</asp:Panel>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</section>
<%-- Submit Button --%>
<section class="box post">
<div class="inputSet">
<asp:UpdatePanel ID="upSubmit" runat="server" UpdateMode="Conditional" AssociatedUpdatePanelID="updateProgress">
<ContentTemplate>
<asp:LinkButton ID="lbSubmit" runat="server" class="button icon fa-info-sign" Style="cursor: pointer;" OnClick="btn_Click" Text="Submit" />
</ContentTemplate>
</asp:UpdatePanel>
</div>
</section>
<div id="popup1" runat="server" class="overlay">
<div class="css_popup">
<h2>Add Component to Database</h2>
<a class="close" href="#">×</a>
<div class="content">
<asp:Panel ID="Panel13" runat="server" CssClass="inputSet2">
<span>Item:</span>
<asp:TextBox ID="txtNewItem" runat="server" CssClass="round-corners " />
</asp:Panel>
<asp:Panel ID="Panel14" runat="server" CssClass="inputSet2">
<span>NSN:</span>
<asp:TextBox ID="txtNewNSN" runat="server" CssClass="round-corners " />
</asp:Panel>
<asp:Panel ID="Panel15" runat="server" CssClass="inputSet2">
<asp:LinkButton ID="lbAddItem" runat="server" class="button icon fa-info-sign" Style="cursor: pointer;" OnClick="btn_Click" Text="Add Item" />
</asp:Panel>
</div>
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</div>
</div>
</div>
</div>
<asp:UpdateProgress ID="updateProgress" runat="server">
<ProgressTemplate>
<div style="position: fixed; text-align: center; height: 100%; width: 100%; top: 0; right: 0; left: 0; z-index: 9999999; background-color: #000000; opacity: 0.7;">
<div class="fancybox-loading">
<asp:Image ID="imgUpdateProgress" runat="server" ImageUrl="~/fancybox/fancybox_loading.gif" AlternateText="Loading ..." ToolTip="Loading ..." Style="margin-top: -22px; margin-left: -22px; position: fixed; top: 51%; left: 51%; background: url('/fancybox/fancybox_sprite2.png'); background-position: 2 -2px;" />
</div>
</div>
</ProgressTemplate>
</asp:UpdateProgress>
The CSS for these elements mirror that of the link provided above.
There is four Div tags in this GridView with ID="NUMBER1" ID="NUMBER2" ID="NUMBER3" ID="NUMBER4" values and i want to change the sequence of their position in page randomly in every row of the gridview.
what is the best and most simple SERVER SIDE method to do this.
I'm new to asp.net using C# language.
<body>
<asp:GridView OnRowCommand="SelectedPollGridView_RowCommand" ID="SelectedPollGridView" runat="server" AutoGenerateColumns="False" DataKeyNames="QuesID" DataSourceID="SelectedPollSqlDataSource">
<Columns>
<asp:TemplateField HeaderText="Questions">
<ItemTemplate>
<div runat="server" id="MainDiv" class="text-right col-md-12">
<div class="row ">
<div dir="rtl" class="col-md-12 text-right">
<p runat="server" id="BodyPTag"><%#Eval("Body") %></p>
<asp:Label Visible="false" ID="QuesIDLabel" runat="server" Text='<%#Eval("QuesID") %>'></asp:Label>
</div>
</div>
<div id="NUMBER1" runat="server" class="row ">
<div class="col-md-12">
<div dir="rtl" runat="server" id="Div2" class="text-right col-md-11">
<asp:Label ID="Label1" runat="server" Text='<%#Eval("O1") %>'></asp:Label>
</div>
<div runat="server" id="Div3" class="text-right col-md-1">
<asp:Button CommandArgument='<%# ((GridViewRow) Container).RowIndex %>' CommandName="O1" CssClass='<%#Eval("O1Css") %>' ID="O1Button" runat="server" Text="Option 1" />
</div>
</div>
</div>
<div id="NUMBER2" runat="server" class="row ">
<div class="col-md-12">
<div dir="rtl" runat="server" id="Div4" class="text-right col-md-11">
<asp:Label ID="Label2" runat="server" Text='<%#Eval("O2") %>'></asp:Label>
</div>
<div runat="server" id="Div5" class="text-right col-md-1">
<asp:Button CommandArgument='<%# ((GridViewRow) Container).RowIndex %>' CommandName="O2" CssClass='<%#Eval("O2Css") %>' ID="O2Button" runat="server" Text="Option 2" />
</div>
</div>
</div>
<div id="NUMBER3" runat="server" class="row ">
<div class="col-md-12">
<div dir="rtl" runat="server" id="Div6" class="text-right col-md-11">
<asp:Label ID="Label3" runat="server" Text='<%#Eval("O3") %>'></asp:Label>
</div>
<div runat="server" id="Div7" class="text-right col-md-1">
<asp:Button CommandArgument='<%# ((GridViewRow) Container).RowIndex %>' CommandName="O3" CssClass='<%#Eval("O3Css") %>' ID="O3Button" runat="server" Text="Option 3" />
</div>
</div>
</div>
<div id="NUMBER4" runat="server" class="row ">
<div class="col-md-12">
<div dir="rtl" runat="server" id="Div8" class="text-right col-md-11">
<asp:Label ID="Label4" runat="server" Text='<%#Eval("O4") %>'></asp:Label>
</div>
<div runat="server" id="Div9" class="text-right col-md-1">
<asp:Button CommandArgument='<%# ((GridViewRow) Container).RowIndex %>' CommandName="O4" CssClass='<%#Eval("O4Css") %>' ID="O4Button" runat="server" Text="Option 4" />
</div>
</div>
</div>
</div>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SelectedPollSqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:GUOTSConnectionString %>" SelectCommand="SELECT DISTINCT QuesID, Body, O1, O2, O4, O3, O1Css, O2Css, O4Css, O3Css, Time, BookRange, UserID, CourseID, Code FROM Question WHERE (UserID = #userid) AND (Code = #code)">
<SelectParameters>
<asp:QueryStringParameter Name="code" QueryStringField="code" />
<asp:SessionParameter Name="userid" SessionField="userid" />
</SelectParameters>
</asp:SqlDataSource>
</body>
the following will do what you want.
Working FIDDLE here
first, change your current divs to give each row a class name we can pick out in our script, like "randomDiv". We could have used "row" but i was afraid you were using that in more places than just these divs.
<div id="NUMBER1" runat="server" class="row randomDiv">
then on document ready run the following javascript:
<script>
$(document).ready(function() {
var divs= $(".randomDiv");
for(var i = 0; i < divs.length; i++){
var target = Math.floor(Math.random() * divs.length -1) + 1;
var target2 = Math.floor(Math.random() * divs.length -1) +1;
divs.eq(target).before(divs.eq(target2));
}
});
</script>
I have a listview control that is nested in the item template of another listview control that i'm trying to reference in codebehind using the .FindControl() method, but it keeps returning null. After get this to work, I'll need to reference a ComboBox inside of the inner listview. Here is where I am so far:
ListView lsvTickets
ItemTemplate
Listview lsvActions
ItemTemplate
ComboBox cboAssignees
I'm using the following code to attempt the reference in code behind:
var actions = (RadListView)lsvTickets.FindControl("lsvActions");
But this is returning null. I thought I would only have to do something like this to achieve the final desired result:
var assignees = (RadComboBox)lsvTickets.FindControl("lsvActions").FindControl("cboAssignees")
Can anyone help? What am I doing wrong here? Here's the full layout for those of you it would help:
<rad:RadListView runat="server" ID="lsvTickets">
<ItemTemplate>
<div id="divContainer" class="divContainer">
<div id="divTicketHeader" class="divTicketHeader">
<asp:Table runat="server" ID="tblTicketHead" Width="100%" CellSpacing="0" CellPadding="5" HorizontalAlign="Center">
<asp:TableRow HorizontalAlign="Center">
<asp:TableCell Width="25%">
<asp:Label ID="Label1" runat="server" Text='<%#Eval("Subject") %>' Font-Bold="true" />
</asp:TableCell><asp:TableCell Width="25%">
<asp:Label ID="Label2" runat="server" Text='<%#Eval("Status.Key") %>' />
</asp:TableCell><asp:TableCell Width="25%">
<asp:Label ID="Label3" runat="server" Text='<%#Eval("Ticket.Reported_By") %>' />
</asp:TableCell><asp:TableCell Width="25%">
<asp:Label ID="Label4" runat="server" Text='<%#Eval("DateOpened") %>' />
</asp:TableCell></asp:TableRow></asp:Table></div>
<div id="divTicketBody" class="divComments">
<rad:RadListView runat="server" ID="lsvActions" DataSource='<%#Eval("TicketActions") %>'>
<ItemTemplate>
<center>
<div id="divAddComment" style="width: 500px;">
<div id="divCommentControls" style="margin: 8px 0px 8px 0px;">
<rad:RadComboBox runat="server" ID="cboStatus" DataSource='<%#GetStatuses() %>' DataTextField="Status" DataValueField="ID" /> <rad:RadComboBox runat="server" ID="cboAssignTo" DataSource='<%#GetAssignees() %>' DataTextField="Key" DataValueField="Value" />
</div>
<rad:RadTextBox runat="server" ID="txtComment" TextMode="MultiLine" Width="500" Height="100" CssClass="commentBox" /><br />
<div style="height: 35px;">
<div style="float:left"><asp:CheckBox ID="cbMakeITTicket" runat="server" Text="Convert to IT Support Ticket" /></div>
<div style="float:right; margin: 3px 0 0 0; "><rad:RadButton runat="server" ID="btnSubmit" Text="Submit" CssClass="buttonTag" /></div>
</div>
</div>
</center>
<div id="divComment" class="divComment">
<asp:Table runat="server" ID="tblComment" CellPadding="5">
<asp:TableRow>
<asp:TableCell Width="15%" HorizontalAlign="Center">
<rad:RadBinaryImage runat="server" ID="imgCommenter" Width="50" Height="50" /><br />
<asp:Label ID="Label5" runat="server" Text="[action author]" CssClass="commenterText" /><br />
<asp:Label ID="Label6" runat="server" Text='<%#Eval("Action_Date", "{0:MMM d, yyy hh:mm}") %>'
CssClass="commenterText"/><br />
</asp:TableCell><asp:TableCell>
<asp:Label ID="Label7" runat="server" Text='<%#Eval("Description") %>' />
</asp:TableCell>
</asp:TableRow>
</asp:Table>
</div>
</ItemTemplate>
</rad:RadListView>
</div>
</div>
</ItemTemplate>
</rad:RadListView>
</asp:Content>
You're looking for a combobox in a control that potentially has many lines (thus rows of combobox instances ) - it doesn’t know which one you’re looking for.
Obviously I don’t know what you need to do to the combobox but you should look at
alternate approaches.
Take a look at using the OnItemDataBound event of lsvActions
Then add code such as …
protected void lsvActions_ItemDataBound(object sender, GridItemEventArgs e)
{
if (e.Item is GridDataItem)
{
GridDataItem item = (GridDataItem)e.Item;
RadComboBox myCBO = (RadComboBox)item.FindControl("cboStatus")
myCBO.Visible = false;
}
}
...also, just a general tip, I usually find using OnNeedDataSource to load RadGrids and ListViews saves a lot of headaches.
Hope that helps.
I have a user control with a bunch of asp:label controls and I need to access their text property from the code behind. Is there an easy way to do this? I tried using the ID.Text of the label, with no luck.
Here is the ascx code:
<div id="labelContainer">
<asp:Label ID="productDescription" class="productDescription fontCaps" runat="server"
Text="express" />
<br />
<asp:Label ID="serviceDescription" class="serviceDescription fontCaps" runat="server"
Text="express 24" />
<div id="shipFrom">
<label class="font8 fontCaps" style="margin-left: 15px;">
From:</label><asp:Label ID="companyName" class="font8 fontCaps" Style="margin-left: 5px;"
runat="server" Text="customer integration management" />
<label class="meeterLabel font8 fontCaps">
MEETER:</label>
<asp:Label ID="meeterNo" class="meeterNumber font8 fontCaps" runat="server" Text="34001" />
<br />
<div id="fromAddress">
<asp:Label ID="fromAddressLine1" class="font8 fontCaps" runat="server" Text="orbital park" />
<br />
<asp:Label ID="fromAddressLine2" class="font8 fontCaps" runat="server" Text="178-188 great west road" />
<br />
<asp:Label ID="fromTown" class="font8 fontCaps" runat="server" Text="hounslow" />
<br />
<asp:Label ID="fromCountry" class="font8 fontCaps" runat="server" Text="middlesex" />
<asp:Label ID="fromPostcode" class="font8 alignRight fontCaps" runat="server" Text="tw4 6js" />
</div>
<div id="toAddress">
<label class="font8 fontCaps">
To:</label><asp:Label ID="orgName" class="font10 addressTabs fontCaps" runat="server"
Text="organisation name" />
<label class="font10 fontCaps" style="margin-left: 100px;">
Tel: </label><asp:Label ID="phone" class="font10 fontCaps" runat="server" Text="0208 818 8000" />
<br />
<asp:Label ID="departmentName" class="font10 addressTabs2 fontCaps" runat="server"
Text="department name" />
<br />
<asp:Label ID="toAddressLine1" class="font10 addressTabs2 fontCaps" runat="server"
Text="address line 1" />
<br />
<asp:Label ID="toAddressLine2" class="font10 addressTabs2 fontCaps" runat="server"
Text="address line 2" />
<br />
<asp:Label ID="toTown" class="font11 addressTabs2 fontCaps" runat="server" Text="town" />
<br />
<asp:Label ID="toCountry" class="font11 addressTabs2 fontCaps" runat="server" Text="county" />
<br />
<asp:Label ID="toPostcode" class="font11 addressTabs2 fontCaps" runat="server" Text="ub5 1aj" />
</div>
<div id="serviceCodeContainer" style="text-align: left;">
<div id="svcCode">
<label style="color: #fff; font-size: 11pt; font-family: Arial; font-weight: bold;
vertical-align: text-top;">
Handling:</label>
<br />
<asp:Label ID="serviceCode" class="fontCaps" Style="margin-left: 18px; font-size: 18pt;"
Text="STD" runat="server" />
</div>
<asp:Label ID="dayTime" class="fontCaps alignFarRight alignTop fontBold font11" runat="server" />
<asp:Label ID="pieceCount" Text="1/1" class="fontCaps pieceCountRight pieceCountTop fontBold font20"
runat="server" />
<label class="font8 fontCaps">
Shipment No: </label><asp:Label ID="shipmentNo"
class="font8 fontCaps" runat="server" Text="123456" />
<br />
<label class="font8 fontCaps">
Consignee Ref: </label><asp:Label ID="consigneeRef" class="font8 fontCaps"
runat="server" Text="Your Customer Reference" />
<br />
<label class="font8 fontCaps">
Consignor Ref: </label><asp:Label ID="consignorRef" class="font8 fontCaps"
runat="server" Text="Your Reference" />
</div>
<div style="text-align: center; margin-bottom: 5px;">
<asp:Label ID="serviceCentre" Style="padding-right: 60px;" class="font20 fontBold fontCaps"
runat="server" Text="hayes" />
<asp:Label ID="hub" class="font20 fontBold fontCaps" runat="server" Text="hatfield" />
</div>
</div>
<div>
<div style="text-align: center; margin-bottom: 5px;">
<asp:Image ID="Image1" ImageUrl="~/images/barcode.jpg" runat="server" />
</div>
<div style="text-align: center; margin-top: 5px; margin-bottom: 5px;">
<asp:Label ID="routingCode" class="font8 fontBold fontCaps" runat="server" Text="2lgbub51aj+01000002" />
</div>
<div style="text-align: center;">
<asp:Image ID="licensePlateImg" ImageUrl="~/images/barcode2.jpg" runat="server" />
</div>
<div style="text-align: center; margin-top: 5px;">
<asp:Label ID="licensePlate" class="font8 fontBold fontCaps" runat="server" Text="(J)JD00 022 340 0100 0124" />
</div>
</div>
But when I try to access it from the code behind of the user control, I get no Text property.
You need to create property in user control like:
public string Label1Text
{
get { return this.label1.Text; }
}
// using
this.myusercontrol.Label1Text;
Or try to find label inside of user control:
((Label)this.myusercontrol.FindControl('label_id')).Text
I do it by creating properties on the user conrtrol
ascx code behind.
public string FirstName
{
get { return FirstNameTextBox.Text; }
set { FirstNameTextBox.text= value; }
}
in the aspx page you can access it as shown:
MyUserControl.FirstName= "Bob";
It's a lot cleaner to access it that way from the aspx than it is to set the TextBox as a public textbox in the Ascx and accessing the TextBox directly.
Expose a property in the user control, like this:
public string LabelText
{
get
{
return Label1.Text;
}
}
And reference the property in the code-behind, like this:
string labelText = UserControl1.LabelText;