Color of output doesn't change - c#

I have this C# event handler that suppose to change the color of the text based on the values of the List View
Here is the code:
protected void YourListView_Load(object sender, EventArgs e)
{
Label theTWALabel;
int theTWAValue;
foreach (ListViewItem item in YourListView.Items)
{
theTWALabel = (Label)item.FindControl("TWALabel");
theTWAValue = Convert.ToInt32(theTWALabel.Text);
if (theTWAValue >= 0)
{
if (theTWAValue < 90)
theTWALabel.ForeColor = System.Drawing.ColorTranslator.FromHtml("YellowThis");
else
theTWALabel.ForeColor = System.Drawing.Color.Red;
}
}
}
and here is the list view line:
<asp:ListView id="YourListView" runat="server" DataSourceID="SqlDataSource3" OnLoad="YourListView_Load" EnableViewState="False">
and here is my list view code:
<asp:ListView id="YourListView" runat="server" DataSourceID="SqlDataSource3" OnLoad="YourListView_Load" EnableViewState="False">
<ItemTemplate>
Plant Name:
<asp:Label id="PlantLabel" runat="server" Text='<%# Eval("Plant") %>' />
<br />
Department #:
<asp:Label id="column1Label" runat="server" Text='<%# Eval("column1") %>' />
<br />
Department Name:
<asp:Label id="GroupLabel" runat="server" Text='<%# Eval("Group") %>' />
<br />
Job Code:
<asp:Label id="Job_CodeLabel" runat="server" Text='<%# Eval("Job_Code") %>' />
<br />
TWA:
<asp:Label id="TWALabel" runat="server" Text='<%# Eval("TWA") %>' />
<br />
Job Classification:
<asp:Label id="Job_ClassificationLabel" runat="server" Text='<%# Eval("Job_Classification") %>' />
<br />
Job Function:
<asp:Label id="Job_FunctionLabel" runat="server" Text='<%# Eval("Job_Function") %>' />
<br />
Job Description:
<asp:Label id="Job_DescriptionLabel" runat="server" Text='<%# Eval("Job_Description") %>' />
<br />
<br />
</ItemTemplate>
<LayoutTemplate>
<div id="itemPlaceholderContainer" runat="server" style="font-family: Verdana, Arial, Helvetica, sans-serif; text-align:center; border:3em; border-color:black;">
<span runat="server" id="itemPlaceholder" />
</div>
</LayoutTemplate>
</asp:ListView>
The Problem is that while it will output my listview values correctly, none of the colors change, and I don't why. Any help would be excellent
Edit: Could it be because of my layout template as that controls all the styling?

Related

how to retrieve binary data in mssql on listview eval

I want to bind a image (which is stored in binary format column name image(varbinary)) in list view in c#..
i am trying this two but not working..
<img src='<%# string.Format("data:image/gif;base64,{0}",Convert.ToBase64String((byte[])Eval("image")))%>'/>--%>
<%--<asp:Image ID="Image10" runat="server" Height="100px" ImageUrl='<%# "ShowImage.ashx?id=" + Eval("image") %>' GenerateEmptyAlternateText="True" Visible='<%# ShowImg(Eval("image")) %>' />--%>
here is the code:
<div>
<h3 class="calDetail">Event Details</h3>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:VeteransDirectoryConnectionString %>" SelectCommand=
"SELECT [EventID], [OrganizationName], [Title], [DescriptionShort], [DescriptionLong], [Location], [EventDate], [URL], (CASE WHEN URL IS NULL OR URL = '' THEN CAST(0 AS bit) ELSE CAST(1 AS bit) END) AS URLLink, [FileName], (CASE WHEN FileName IS NULL OR FileName = '' THEN CAST(0 AS bit) ELSE CAST(1 AS bit) END) AS FileLink, [EventTime],image FROM [t_Event] WHERE ([EventID] = #EventID)">
<SelectParameters>
<asp:QueryStringParameter Name="EventID" QueryStringField="eventid" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
<br />
<div style="padding: 0px 10px 20px 10px;">
<asp:ListView ID="ListView1" runat="server" DataKeyNames="EventID" DataSourceID="SqlDataSource1">
<EmptyDataTemplate>
<span>No data for this event was found.</span>
</EmptyDataTemplate>
<ItemTemplate>
<span class="listCalLabel">Organization:</span>
<asp:Label ID="OrganizationNameLabel" runat="server" Text='<%# Eval("OrganizationName") %>' CssClass="listCalText" />
<br /><br />
<span class="listCalLabel">Event:</span>
<asp:Label ID="TitleLabel" runat="server" Text='<%# Eval("Title") %>' CssClass="listCalText" />
<br /><br />
<span class="listCalLabel">Short Description:</span>
<asp:Label ID="DescriptionShortLabel" runat="server" Text='<%# Eval("DescriptionShort") %>' CssClass="listCalText" />
<br /><br />
<span class="listCalLabel">Long Description:</span>
<asp:Label ID="DescriptionLongLabel" runat="server" Text='<%# Eval("DescriptionLong") %>' CssClass="listCalText" />
<br /><br />
<span class="listCalLabel">Location:</span>
<asp:Label ID="LocationLabel" runat="server" Text='<%# Eval("Location") %>' CssClass="listCalText" />
<br /><br />
<span class="listCalLabel">Event Date:</span>
<asp:Label ID="EventDateLabel" runat="server" Text='<%# Eval("EventDate", "{0:MM/dd/yyyy}") %>' CssClass="listCalText" />
<br /><br />
<span class="listCalLabel">Event Time:</span>
<asp:Label ID="EventTimeLabel" runat="server" Text='<%# Eval("EventTime") %>' CssClass="listCalText" />
<br /><br />
<span class="listCalLabel"><asp:Label ID="lblURL" runat="server" Visible='<%# Eval("URLLink") %>' Text="Additional Info (website):" ></asp:Label></span>
<br />
<asp:HyperLink ID="URLHyperLink" runat="server" Text='<%# Eval("URL") %>' NavigateUrl='<%# Eval("URL") %>' Visible='<%# Eval("URLLink") %>' Target="_blank" CssClass="listLink" />
<br /><br />
<span class="listCalLabel"><asp:Label ID="lblFile" runat="server" Visible='<%# Eval("FileLink") %>' Text="Additional Info (file):"></asp:Label></span>
<br />
<asp:HyperLink ID="URLFile" runat="server" Text='<%# Eval("FileName") %>' NavigateUrl='<%# "EventFiles/" + Eval("FileName") %>' Visible='<%# Eval("FileLink") %>' Target="_blank" CssClass="listLink" />
<br /><br />
<%-- <img src='<%# string.Format("data:image/gif;base64,{0}",Convert.ToBase64String((byte[])Eval("image")))%>'/>--%>
<%--<asp:Image ID="Image10" runat="server" Height="100px" ImageUrl='<%# "ShowImage.ashx?id=" + Eval("image") %>' GenerateEmptyAlternateText="True" Visible='<%# ShowImg(Eval("image")) %>' />--%>
<br /></span>
</ItemTemplate>
<LayoutTemplate>
<div id="itemPlaceholderContainer" runat="server" style="">
<span runat="server" id="itemPlaceholder" />
</div>
<div style="">
</div>
</LayoutTemplate>
</asp:ListView>
<asp:Button ID="btnOK" runat="server" OnClientClick="window.close(); return false;" Text="Close Event Detail" CssClass="btn btn-default" />
<br />
<br />
</div>
</div>
what should i do???
how to retrieve the image and show ina a webform ??
You can use handler to display image in gridview , your html markup look like inside
Gridview ItemTemplate set image control src as src=~/getImage.ashx?id=" + id
where getImage.ashx is your handler which return MemoryStream((byte[])img);
for more details read http://www.aspdotnet-suresh.com/2015/07/save-retrieve-display-binary-images-in-gridview-from-database-in-aspnet-csharp-vbnet.html

I have an error in my listview

these is the problem:
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0118: 'System.Web.UI.WebControls.SqlDataSource' is a 'type' but is used like a 'variable'
Source Error:
Line 31:
Line 32:
Line 33: " runat="server"
Line 35: DataSourceID="SqlDataSource1"
This is my codes:
<asp:ListView ID="ListView1" GroupItemCount="3" DataKeyNames="pic_id"
DataSource="<%# SqlDataSource %>" runat="server"
DataSourceID="SqlDataSource1"
onselectedindexchanged="ListView1_SelectedIndexChanged">
<AlternatingItemTemplate>
<td runat="server" style="background-color: #FFFFFF;color: #284775;">
pic_id:
<asp:Label ID="pic_idLabel" runat="server" Text='<%# Eval("pic_id") %>' />
<br />
picture_tag:
<asp:Label ID="picture_tagLabel" runat="server"
Text='<%# Eval("picture_tag") %>' />
<br />
pic:
<asp:Label ID="picLabel" runat="server" Text='<%# Eval("pic") %>' />
<br />
</td>
</AlternatingItemTemplate>
<EmptyDataTemplate>
<table runat="server"
style="background-color: #FFFFFF;border-collapse: collapse;border-color: #999999;border-style:none;border-width:1px;">
<tr>
<td>
No data was returned.</td>
</tr>
</table>
</EmptyDataTemplate>
<InsertItemTemplate>
<td runat="server" style="">
picture_tag:
<asp:TextBox ID="picture_tagTextBox" runat="server"
Text='<%# Bind("picture_tag") %>' />
<br />
pic:
<asp:TextBox ID="picTextBox" runat="server" Text='<%# Bind("pic") %>' />
<br />
<asp:Button ID="InsertButton" runat="server" CommandName="Insert"
Text="Insert" />
<br />
<asp:Button ID="CancelButton" runat="server" CommandName="Cancel"
Text="Clear" />
<br />
</td>
</InsertItemTemplate>
<LayoutTemplate>
<table runat="server">
<tr runat="server">
<td runat="server">
<table ID="groupPlaceholderContainer" runat="server" border="1"
style="background-color: #FFFFFF;border-collapse: collapse;border-color: #999999;border-style:none;border-width:1px;font-family: Verdana, Arial, Helvetica, sans-serif;">
<tr ID="groupPlaceholder" runat="server">
</tr>
</table>
</td>
</tr>
<tr runat="server">
<td runat="server"
style="text-align: center;background-color: #5D7B9D;font-family: Verdana, Arial, Helvetica, sans-serif;color: #FFFFFF">
<asp:DataPager ID="DataPager1" runat="server" PageSize="12">
<Fields>
<asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True"
ShowLastPageButton="True" />
</Fields>
</asp:DataPager>
</td>
</tr>
</table>
</LayoutTemplate>
<EditItemTemplate>
<td runat="server" style="background-color: #999999;">
pic_id:
<asp:Label ID="pic_idLabel1" runat="server" Text='<%# Eval("pic_id") %>' />
<br />
picture_tag:
<asp:TextBox ID="picture_tagTextBox" runat="server"
Text='<%# Bind("picture_tag") %>' />
<br />
pic:
<asp:TextBox ID="picTextBox" runat="server" Text='<%# Bind("pic") %>' />
<br />
<asp:Button ID="UpdateButton" runat="server" CommandName="Update"
Text="Update" />
<br />
<asp:Button ID="CancelButton" runat="server" CommandName="Cancel"
Text="Cancel" />
<br />
</td>
</EditItemTemplate>
<GroupTemplate>
<tr ID="itemPlaceholderContainer" runat="server">
<td ID="itemPlaceholder" runat="server">
</td>
</tr>
</GroupTemplate>
<EmptyItemTemplate>
<td runat="server" />
</EmptyItemTemplate>
<ItemTemplate>
<td runat="server" style="background-color: #E0FFFF;color: #333333;">
pic_id:
<asp:Label ID="pic_idLabel" runat="server" Text='<%# Eval("pic_id") %>' />
<br />
picture_tag:
<asp:Label ID="picture_tagLabel" runat="server"
Text='<%# Eval("picture_tag") %>' />
<br />
pic:
<asp:Label ID="picLabel" runat="server" Text='<%# Eval("pic") %>' />
<br />
</td>
</ItemTemplate>
<SelectedItemTemplate>
<td runat="server"
style="background-color: #E2DED6;font-weight: bold;color: #333333;">
pic_id:
<asp:Label ID="pic_idLabel" runat="server" Text='<%# Eval("pic_id") %>' />
<br />
picture_tag:
<asp:Label ID="picture_tagLabel" runat="server"
Text='<%# Eval("picture_tag") %>' />
<br />
pic:
<asp:Label ID="picLabel" runat="server" Text='<%# Eval("pic") %>' />
<br />
</td>
</SelectedItemTemplate>
</asp:ListView>
Remove DataSource="<%# SqlDataSource %>"
from the ListView definition
If you have bind listview from back end than you can't add Datasource on front size...

Trying to Change the color of the background label in ListView

I am trying to change the color of the background when twa is at different values but it with my current code, the data is not firing, but when I remove the
<asp: Label id="TWAlabel" OnDataBinding="ListView2_OnDataBinding">
But when I remove OnDataBinding the data fires, so I have no idea what is wrong. I am doing this in Asp.net(C#), JavaScript, and the data is sourced from an Access database. Here is my code:
<style>
.YellowThis
{
background-color:yellow;
}
.RedThis
{
background-color:red;
}
.GreenThis
{
background-color:green;
}
</style> <asp:ListView id="ListView2" runat="server" DataSourceID="SqlDataSource3" EnableViewState="False">
</InsertItemTemplate>
<ItemTemplate>
<span style="background-color: white;color: #333333; border: 2em; border-width:1em; border-color:black;">
Plant Name:
<asp:Label id="PlantLabel" runat="server" Text='<%# Eval("Plant") %>' />
<br />
Department #:
<asp:Label id="column1Label" runat="server" Text='<%# Eval("column1") %>' />
<br />
Department Name:
<asp:Label id="GroupLabel" runat="server" Text='<%# Eval("Group") %>' />
<br />
Job Code:
<asp:Label id="Job_CodeLabel" runat="server" Text='<%# Eval("Job_Code") %>' />
<br />
TWA:
<asp:Label id="TWALabel" OnDataBinding="ListView2_DataBinding" runat="server" Text='<%# Eval("TWA") %>' />
<br />
Job Classification:
<asp:Label id="Job_ClassificationLabel" runat="server" Text='<%# Eval("Job_Classification") %>' />
<br />
Job Function:
<asp:Label id="Job_FunctionLabel" runat="server" Text='<%# Eval("Job_Function") %>' />
<br />
Job Description:
<asp:Label id="Job_DescriptionLabel" runat="server" Text='<%# Eval("Job_Description") %>' />
<br />
<br />
</span>
</ItemTemplate>
<LayoutTemplate>
<div id="itemPlaceholderContainer" runat="server" style="font-family: Verdana, Arial, Helvetica, sans-serif; text-align:center; border:3em; border-color:black;">
<span runat="server" id="itemPlaceholder" />
</div>
<div style="text-align: left;background-color: white;font-family: Verdana, Arial, Helvetica, sans-serif;text-decoration:underline ;color: #FFFFFF;" >
</div>
</LayoutTemplate>
<SelectedItemTemplate>
<span style="background-color: white;font-weight: bold;color: #333333;">
<u>Plant Name</u>:
<asp:Label id="PlantLabel" runat="server" Text='<%# Eval("Plant") %>' />
<br />
Department #:
<asp:Label id="column1Label" runat="server" Text='<%# Eval("column1") %>' />
<br />
Department Name:
<asp:Label id="GroupLabel" runat="server" Text='<%# Eval("Group") %>' />
<br />
Job Code:
<asp:Label id="Job_CodeLabel" runat="server" Text='<%# Eval("Job_Code") %>' />
<br />
TWA:
<asp:Label id="TWALabel" runat="server" Text='<%# Eval("TWA") %>' />
<br />
Job Classification:
<asp:Label id="Job_ClassificationLabel" runat="server" Text='<%# Eval("Job_Classification") %>' />
<br />
Job Function:
<asp:Label id="Job_FunctionLabel" runat="server" Text='<%# Eval("Job_Function") %>' />
<br />
Job Description:
<asp:Label id="Job_DescriptionLabel" runat="server" Text='<%# Eval("Job_Description") %>' />
<br />
<br />
</span>
</SelectedItemTemplate>
</asp:ListView>
<script runat="server">
protected void ListView2_DataBinding(object sender, EventArgs e)
{
Label lbl = (Label)(sender);
int TWA = (int)(Eval("TWA"));
lbl.Text = TWA.ToString();
if (TWA >= 85)
{
if (TWA < 90)
{
lbl.CssClass = "YellowThis";
}
else
{
lbl.CssClass = "RedThis";
}
}
else
{
lbl.CssClass="GreenThis";
}
}
</script>
You could do it in your code behind. Iterate through your list items.
protected void add_color()
{
foreach(ListItem li in ListView2.Items)
{
Label your_label = (Label)li.FindControl" your_label_name";
int TWA = Convert.ToInt32(your_label);
if (TWA > 90)
{
your_label.BackColor = System.Drawing.Color.Yellow
}
}
}
This questions is more than 1 year old and I'm not sure if it'll help anyone here.
I think what went wrong in your code is because your listview databinding event was created in Label instead of creating it in the Listview.
What you can do is create a databinding event in ListView control and read the value of the TWA label and then set your ListView control background color.

ModalPopupExtender inside DataList show up onclick of ImageButton inside datalist item

I have a datalist filled with items from database and each item has an image button onclick of which I want to show a modalpopup containing the Description of the particular Item. Below is what I have dine so far but fail:
<asp:DataList ID="DataList1" runat="server" RepeatColumns="3" RepeatDirection="Horizontal" Width="100%">
<ItemTemplate>
<table width="228px">
<tr>
<td width="20px" > </td>
<td width="160px" align="center">
<asp:Label ID="pID" runat="server" Visible="false" Text='<%# Eval("id") %>'></asp:Label><asp:Label ID="Label1" runat="server" Text='<%# Eval("ProductName") %>' Font-Size="8pt" ForeColor="#336699" Width="100%" />
</td>
<td align="right">
<asp:ImageButton ID="SpecificBtn" ImageUrl="images/SmallCallout.png" OnClick="SpecificBtn_Click" CommandArgument='<%# Eval("Id") %>' runat="server" />
<ajaxToolkit:ModalPopupExtender ID="mdl" runat="server" PopupControlID="pnl" TargetControlID="SpecificBtn" Enabled="True" CancelControlID="btn" DropShadow="true" Drag="True" ></ajaxToolkit:ModalPopupExtender>
</td>
</tr>
</table>
<asp:Image ID="Image1" runat="server" ImageUrl='<%# "GetImage.aspx?id=" + Eval("id") %>' /><br />
<table align="center" style="position:relative; left:2px;" cellspacing="0" cellpadding = "0" width="228px">
<tr>
<td style="background-color:Black;" colspan=2>
<div >
<asp:Image ID="Image2" ImageUrl="/images/cart.png" runat="server" />
<asp:Button CommandName="AddToCart" CssClass="anchor" OnClick="addProduct" CausesValidation="false" CommandArgument='<%# Eval("Id") %>' ID="addToHire" runat="server" Text=" Add To Cart " BackColor="Black" BorderColor="Black" BorderStyle="None" ForeColor="#F8CD20" Height="24" Font-Bold="true" Font-Size="10" />
</div>
</td>
</tr>
</table>
<br /><br />
</ItemTemplate>
<ItemStyle CssClass="dataListItemStyle" HorizontalAlign="Center" VerticalAlign="Top" />
</asp:DataList>
<asp:Panel ID="pnl" runat="server" visible="false" Width="300px" Height="300px" BackColor="red">
<asp:Label ID="Label2" runat="server" Text="Specification"></asp:Label>
<asp:Label ID="Label3" runat="server" Text='<%# Eval("Specification") %>'></asp:Label>
<asp:Button ID="btn" runat="server" Text="cancel" />
</asp:Panel>
Code behind:
protected void SpecificBtn_Click(object sender, EventArgs e)
{
DataListItem dli = (DataListItem)((ImageButton)sender).Parent;
ModalPopupExtender ModalPopupExtender2 = (ModalPopupExtender)dli.FindControl("mdl");
pnl.Visible = true;
ModalPopupExtender2.Show();
}
Can somebody tell me how to acheive this and where I went wrong. Thanks.
use jquery..
function onimagebuttonclick()
{
$find('BehaviorIDofmodelpopupextender').show();
}
i hope this solves your problem..

Panel visibilty on/off toggle effect not working

I've a got ListBox called lbxUpcommingEvents. When the index is changed the event handler is fired to check for duplicate records. If duplicates are not found, a panel called pnlAction inside a formview is turned on by the way of display style. If dups are found another panel pnlActionCancel is turned on and the oter is tuned off. Basically a toogle effect.
I've tried the visible property, viewstate property, but it does not work and I can't figure it out so once again, I seek wizdom from the collective. Here is my code.
protected void lbxUpcommingEvents_OnSelectedIndexChanged(object sender, EventArgs e)
{
pnlEventsSignUp.Visible = true;
string _selectedItemValue = lbxUpcommingEvents.SelectedValue.ToString();
int _eventid = Convert.ToInt32(_selectedItemValue);
Guid _memberId = Guid.Empty;
_memberId = new Guid(Session["myId"].ToString());
// Check for existing signup
EventsMemberSignup _createSingup = new EventsMemberSignup();
dsEventsSingupTableAdapters.MemberEventsTableAdapter da = new dsEventsSingupTableAdapters.MemberEventsTableAdapter();
dsEventsSingup.MemberEventsDataTable dt = da.GetDataForDupCheck(_memberId, _eventid);
if (dt.Rows.Count == 1)
{
Panel pnlAction = (Panel)(fvEventSignUp.FindControl("pnlAction"));
//pnlAction.Visible = false;
pnlAction.Style.Add("display","none");
Panel pnlActionCancel = (Panel)(fvEventSignUp.FindControl("pnlActionCancel"));
//pnlActionCancel.Visible = true;
pnlActionCancel.Style.Remove("display");
}
else
{
Panel pnlActionCancel = (Panel)(fvEventSignUp.FindControl("pnlActionCancel"));
//pnlActionCancel.Visible = false;
pnlActionCancel.Style.Add("display", "none");
Panel pnlAction = (Panel)(fvEventSignUp.FindControl("pnlAction"));
//pnlAction.Visible = true;
pnlAction.Style.Remove("display");
}
}
<div id="columnleft">
<a name="content_start" id="content_start"></a>
<div class="leftblock">
<h2>Events Signup</h2>
<p>
</p>
<h3> Upcomming Events</h3>
<p>
<asp:ListBox ID="lbxUpcommingEvents" runat="server" DataSourceID="odsUpcommingEvents"
Rows="6" DataTextField="Title" DataValueField="id" AutoPostBack="true"
Width="206px" OnSelectedIndexChanged="lbxUpcommingEvents_OnSelectedIndexChanged" />
</p>
<h3> Members Attending</h3>
<p>
<asp:DataGrid ID="lboxSignedUpMembers" runat="server" DataSourceID="odsSignedUpMembers"
AutoPostBack="true" AutoGenerateColumns="false" RowStyle-CssClass="gridview" AlternatingRowStyle-CssClass="altbgcolor"
Width="206px" onselectedindexchanged="lboxSignedUpMembers_SelectedIndexChanged" CssClass="gridview"
GridLines="None" BorderStyle="Solid" BorderWidth="1" BorderColor="Black" >
<AlternatingItemStyle BackColor="White" />
<Columns>
<asp:BoundColumn DataField="Name" />
<asp:BoundColumn DataField="Title" />
<asp:TemplateColumn >
<ItemTemplate>
<asp:Label runat="server" ID="lblDate" Text='<%# Eval("StartTime", "{0:d}") %>' />
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>
</p>
</div>
</div>
</td>
<td align="left" >
<!--Start of right column-->
<div id="columnright">
<div class="rightblock">
<asp:Panel ID="pnlEventsSignUpTitle" runat="server" CssClass="actionbuttons">
<h2>Select an Event to Signup</h2>
</asp:Panel>
<asp:Label runat="server" ID="lblNote" ForeColor="#cc0000" Font-Bold="true" />
</div>
<div class="rightblock">
<asp:Panel runat="server" ID="pnlEventsSignUp" visible="false">
<div class="dashedline" ></div>
<asp:FormView ID="fvEventSignUp" runat="server" DataSourceID="ObjectDataSource1"
DataKeyNames="id" Width="100%" >
<ItemTemplate>
<h2>
<asp:HiddenField runat="server" ID="hfEventID" Value='<%# Eval("id") %>' />
<asp:Label Text='<%# Eval("title") %>' runat="server" ID="titleLabel" />
</h2>
<div class="itemdetails">
<br />
location:
<h3>
<asp:Label ID="locationLabel" runat="server" Text='<%# ShowLocationLink(Eval("locationname"),Eval("location")) %>' />
</h3>
<p>
<asp:Label Text='<%# Eval("starttime","{0:D}") %>' runat="server" ID="itemdateLabel" CssClass="GeneralText" />
<asp:Label Text='<%# ShowDuration(Eval("starttime"),Eval("endtime")) %>' runat="server" ID="Label1" CssClass="GeneralText" />
</p>
</div>
<div class="downloadevent">
<a href="#">
<img src="images/icon_download_event.gif" alt="Download this event to your personal calendar"
width="15" height="26" /></a><a href='<%# "events_download.ashx?EventID=" + Convert.ToString(Eval("id")) %>'>Add
this event to your personal calendar</a>
</div>
<Club:ImageThumbnail ID="thumb1" runat="server" ImageSize="Large" PhotoID='<%# Eval("photo") %>' />
<p>
<asp:Label Text='<%# Eval("description") %>' runat="server" ID="descriptionLabel" />
</p>
<div class="dashedline" ></div>
<asp:Panel ID="pnlAction" runat="server" CssClass="actionbuttons" >
<table border="0" cellpadding="2" cellspacing="2">
<tr>
<td>
<asp:Label runat="server" ID="Label2" Text="Action<br />Required" Width="80px" Font-Bold="true"
ForeColor="#cc0000" Font-Size="14px" />
</td>
<td>
<img src="images/RedArrow.jpg" alt="Red Arrow Right" />
</td>
<td>
<asp:CheckBox runat="server" ID="cbxCert" Height="30px" Text="Check to Confirm Attendance" /><br />
<asp:CustomValidator runat="server" ID="rfvConfirm"
ErrorMessage="You must check the box to continue" Font-Bold="true"
ForeColor="#cc0000" ClientValidationFunction="ensureChecked" /> <br />
<Club:RolloverLink ID="rlnkSignUp" runat="server" Text = "I will be attending this event"
OnClick="rlnkSignUp_OnClick" ToolTip="I hereby certify that I am commiting to attending this event."
/>
</td>
</tr>
</table>
</asp:Panel>
<asp:Panel runat="server" ID="pnlActionCancel" CssClass="actionbuttons" >
<table border="0" cellpadding="2" cellspacing="2">
<tr>
<td>
<asp:Label runat="server" ID="lblDupSignup" Text="You are alredy signed up for this event" ForeColor="#cc0000" Font-Bold="true" Font-Size="14px" />
</td>
<td>
</td>
<td>
<asp:CheckBox runat="server" ID="cbxCancel" Height="30px" Text="Check to Cancel Attendance" /><br />
<asp:CustomValidator runat="server" ID="CustomValidator1"
ErrorMessage="You must check the box to continue" Font-Bold="true"
ForeColor="#cc0000" ClientValidationFunction="ensureChecked" /> <br />
<Club:RolloverLink ID="rlnCancel" runat="server" Text="I'm cancelling my participation"
OnClick="rlnCancel_OnClick" />
</td>
</tr>
</table>
</asp:Panel>
</ItemTemplate>
</asp:FormView>
</asp:Panel>
</div>
I've set the ViewStateMode to "Disabled". I'm just hoping it won't back fire somewhere else.
Your existing code might work if you drop an update panel and place your controls inside it.
Alternatively you can create a property in your page like
private bool myRowCount;
protected bool HasRowsMyData
{
get { return myRowCount; }
set { myRowCount=value; }
}
Then inside your selectedIndex change event
if (dt.Rows.Count == 1)
{
HasRowsMyData=true;
//DataBind your controls here
YourUpdatePanel.Update();
}
Inside your aspx on panels you can set each panel's visible property like this so whenever page is updated they will turn on/off depeding upon the result
Visible='<%#HasRowsMyData%>'
Visible='<%#!HasRowsMyData%>'
If you like to do it client side I advise jQuery's toggle function
jQuey:toggle()

Categories