473,608 Members | 2,378 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Highlight datalist row on itemDataBound event

I am having a problem highlighting a row in a datalist during the
itemdatabound event. What is occurring is that a new td row is being wrapped
around the datalist item which is highlighted (very small), but the actual
row that I want to be highlighted is not. Style is being applied to the wrong
td row.
Following is my code for webform:

<asp:datalist ID="dlSmartKeys " Width="700" CellPadding="0"
CellSpacing="0" Runat="server">
<headertemplate >
<tr valign="top" align="right" bgColor="#d3d3d 3">
<td class="datahead er" align="left">#</td>
<td class="datahead er" align="left" title="GCN Number">Gcn</td>
<td class="datahead er" align="left" title="Sk_Stc_C de">Stc
Code</td>
<td class="datahead er" align="left" title="Sk_Hicl_ Cde">Hicl
Code</td>
<td class="datahead er" align="left"
title="Sk_Stren gth_Cde">Streng th Code</td>
<td class="datahead er" align="left"
title="Sk_Dosag e_Form_Cde">Dos age Form Code</td>
<td class="datahead er" align="left"
title="Sk_Admin _Route_Cde">Adm in Route Code</td>
</tr>
</headertemplate>
<itemtemplate >
<tr valign="center" align="right" bgcolor="#f5f5f 5">
<input id="object_key " type="hidden" value='<%#
DataBinder.Eval (Container.Data Item, "object_key")%> ' runat="server">
<td class="data" align="left" width="10"><%=C ounter%>.</td>
<td class="data" align="left">
<asp:textbox ID="txtGCN" Text='<%# (DataBinder.Eva l (
Container, "DataItem.Gcn_N br")).ToString( ).Trim() %>' Width="50"
MaxLength="5" Runat="server">
</asp:textbox></td>
<td class="data" align="left">
<asp:textbox ID="txtSTC" Text='<%# (DataBinder.Eva l (
Container, "DataItem.Sk_St c_Cde")).ToStri ng().Trim() %>' Width="50"
MaxLength="4" Runat="server"> abc</asp:textbox></td>
<td class="data" align="left">
<asp:textbox ID="txtHICL" Text='<%# (DataBinder.Eva l (
Container, "DataItem.Sk_Hi cl_Cde")).ToStr ing().Trim() %>' Width="50"
MaxLength="5" Runat="server"> abc</asp:textbox></td>
<td class="data" align="left">
<asp:textbox ID="txtSTR" Text='<%# (DataBinder.Eva l (
Container, "DataItem.Sk_St rength_Cde")).T oString().Trim( ) %>' Width="50"
MaxLength="4" Runat="server"> abc</asp:textbox></td>
<td class="data" align="left">
<asp:textbox ID="txtDOS" Text='<%# (DataBinder.Eva l (
Container, "DataItem.Sk_Do sage_Form_Cde") ).ToString().Tr im() %>' Width="50"
MaxLength="3" Runat="server"> abc</asp:textbox></td>
<td class="data" align="left">
<asp:textbox ID="txtRTE" Text='<%# (DataBinder.Eva l (
Container, "DataItem.Sk_Ad min_Route_Cde") ).ToString().Tr im() %>' Width="50"
MaxLength="2" Runat="server"> abc</asp:textbox></td>
</tr>
</itemtemplate>
<footertemplate >
<tr valign="center" align="right" bgColor="dcdcdc " height="28">
<td colspan="20" align="center">
<asp:button ID="btnSubmit" OnClick="btnSub mit_OnClick"
Text="Submit Changes" CssClass="grayg obtn" Runat="server"> </asp:button></td>
</tr>
</footertemplate>
</asp:datalist>
and the codebehind:

private void dlSmartKeys_Ite mDataBound(obje ct sender,
System.Web.UI.W ebControls.Data ListItemEventAr gs e)
{
if (e.Item.ItemTyp e == ListItemType.Al ternatingItem || e.Item.ItemType ==
ListItemType.It em )
{
... biz logic
// highlight row if condition met
if (cond)
{
e.Item.BackColo r=System.Drawin g.Color.Red;
}
}
}

and when rendered, you can see the problem i am referring to....the new
outer td is receiving the style
<td style="backgrou nd-color:Red;">
<tr valign="center" align="right" bgcolor="#f5f5f 5">
<input name="dlSmartKe ys:_ctl1:object _key"
id="dlSmartKeys __ctl1_object_k ey" type="hidden" value="702" />
<td class="data" align="left" width="10">1.</td>
<td class="data" align="left">
<input name="dlSmartKe ys:_ctl1:txtGCN " type="text"
maxlength="5" id="dlSmartKeys __ctl1_txtGCN" style="width:50 px;" /></td>
<td class="data" align="left">
<input name="dlSmartKe ys:_ctl1:txtSTC " type="text"
maxlength="4" id="dlSmartKeys __ctl1_txtSTC" style="width:50 px;" /></td>
<td class="data" align="left">
<input name="dlSmartKe ys:_ctl1:txtHIC L" type="text"
value="18694" maxlength="5" id="dlSmartKeys __ctl1_txtHICL"
style="width:50 px;" /></td>
<td class="data" align="left">
<input name="dlSmartKe ys:_ctl1:txtSTR " type="text" value="0240"
maxlength="4" id="dlSmartKeys __ctl1_txtSTR" style="width:50 px;" /></td>
<td class="data" align="left">
<input name="dlSmartKe ys:_ctl1:txtDOS " type="text"
maxlength="3" id="dlSmartKeys __ctl1_txtDOS" style="width:50 px;" /></td>
<td class="data" align="left">
<input name="dlSmartKe ys:_ctl1:txtRTE " type="text"
maxlength="2" id="dlSmartKeys __ctl1_txtRTE" style="width:50 px;" /></td>
</tr>
</td>
Nov 19 '05 #1
0 1425

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
8289
by: jenn | last post by:
Hi Anyone knows how to access to a value of a row in a datalist. Something like this in datagrid Dim str = MyDataGrid.Cell(0).tex I would like something like this Dim str = DataBinder.Eval(MyDatalist.Items(count).DataItem, "customerId") but it doesn't work.
2
3042
by: Shiju Poyilil | last post by:
Hi ! I have a requirement wherein i am binding a datalist which contains a label (Caption for the field) and some literal hidden fields and a dropdown list. When I am binding to the datalist.. only the labels (caption) and the invisible literal controls are binded.. Now based on the invisible literal control values I get the information from DB to bind it with each dropdown list (I am doing this in the item databound event) Also based on...
5
13381
by: Patrick.O.Ige | last post by:
I'm binding a CheckBoxlist below in the ItemDataBound(the CheckBoxList is in a Datalist) By doing "li.Selected = True" i can see all the checkBoxes are selected. But what i want is to be able to get a Boolean value TRUE or FALSE when a checkBox is selected. When the checkBoxList was out of the DataList i used "OnSelectedIndexChanged" and it was returning what i wanted but if its in a
4
4033
by: Patrick.O.Ige | last post by:
I have a CheckBoxList in a DataList and i'm trying to get item Selected after doing a postBack. I have set my CheckBoxlist AutoPostBack="True" Any ideas what 'm doing wrong? It seems not to work:( Thanks My CheckBoxList in the DataList Below
0
8067
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8010
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8501
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8157
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8349
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6820
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6015
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5479
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
1607
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.