473,395 Members | 1,383 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

highlight a datagrid template row?

I've searched, reviewed, and attempted dozens of code ideas on the subject. I
can't seem to get something that seems so simple to work. To highlight a row
in a datagrid based on another value in that row.

I have a datagrid using Template and Item Columns, i.e.:

<asp:TemplateColumn HeaderText="CA Date Req"
HeaderStyle-CssClass="gridqtext" ItemStyle-CssClass="gridtext">
<ItemTemplate>
<asp:Label ID="lblcadatereq" CssClass="gridtext" width="75" Runat="server"
Text='<%# DataBinder.Eval(Container.DataItem, "Concern_DCADate", "{0:d}") %>'
Visible="True">
</asp:Label>
</ItemTemplate>
</asp:TemplateColumn>

I've tried both Oncreate and OnDataBound, no luck. I have several columns,
but I need values from checkbox (#3) and Label (#4). I've tried, etc.:
CType(E.Item.FindControl("lblcadatereq"), Label).Text

What is strange is that when I run (Onitemcreated):

Response.Write("value = " & e.Item.Cells(4).Text & "<br>")

I get, there are four rows in my grid (header, two data, a blank bottom
row). I get:
#1 value = "Title of Header"
#2 - 4 value = (is blank). The grid shows data in #2 and #3???

I have also ran a routine to remove the first and last rows using:
e.Item.ItemType = ListItemType.Item Or e.Item.ItemType =
ListItemType.AlternatingItem
but still no values from grid for rows 2 and 3????

Nov 19 '05 #1
4 2162
It is not clear from the message what is your immediate problem. You can't
get a value of a bound column? Bound columns get value in ItemDataBound
event. Also you can use PreRender event in which the grid is already fully
populated with all values.

Eliyahu

"Chris" <Ch***@discussions.microsoft.com> wrote in message
news:36**********************************@microsof t.com...
I've searched, reviewed, and attempted dozens of code ideas on the subject. I can't seem to get something that seems so simple to work. To highlight a row in a datagrid based on another value in that row.

I have a datagrid using Template and Item Columns, i.e.:

<asp:TemplateColumn HeaderText="CA Date Req"
HeaderStyle-CssClass="gridqtext" ItemStyle-CssClass="gridtext">
<ItemTemplate>
<asp:Label ID="lblcadatereq" CssClass="gridtext" width="75" Runat="server"
Text='<%# DataBinder.Eval(Container.DataItem, "Concern_DCADate", "{0:d}") %>' Visible="True">
</asp:Label>
</ItemTemplate>
</asp:TemplateColumn>

I've tried both Oncreate and OnDataBound, no luck. I have several columns,
but I need values from checkbox (#3) and Label (#4). I've tried, etc.:
CType(E.Item.FindControl("lblcadatereq"), Label).Text

What is strange is that when I run (Onitemcreated):

Response.Write("value = " & e.Item.Cells(4).Text & "<br>")

I get, there are four rows in my grid (header, two data, a blank bottom
row). I get:
#1 value = "Title of Header"
#2 - 4 value = (is blank). The grid shows data in #2 and #3???

I have also ran a routine to remove the first and last rows using:
e.Item.ItemType = ListItemType.Item Or e.Item.ItemType =
ListItemType.AlternatingItem
but still no values from grid for rows 2 and 3????

Nov 19 '05 #2
I would say that you were on the right track with the OnItemDataBound Event.
This fires before the binding so basically you can grab values from your
datsource and do some conditional logic. OnItemCreated Event also comes to
mind; but somehow I don't think this would give you a solution for this.
They got to have code sames for this out there.
"Chris" <Ch***@discussions.microsoft.com> wrote in message
news:36**********************************@microsof t.com...
I've searched, reviewed, and attempted dozens of code ideas on the
subject. I
can't seem to get something that seems so simple to work. To highlight a
row
in a datagrid based on another value in that row.

I have a datagrid using Template and Item Columns, i.e.:

<asp:TemplateColumn HeaderText="CA Date Req"
HeaderStyle-CssClass="gridqtext" ItemStyle-CssClass="gridtext">
<ItemTemplate>
<asp:Label ID="lblcadatereq" CssClass="gridtext" width="75" Runat="server"
Text='<%# DataBinder.Eval(Container.DataItem, "Concern_DCADate", "{0:d}")
%>'
Visible="True">
</asp:Label>
</ItemTemplate>
</asp:TemplateColumn>

I've tried both Oncreate and OnDataBound, no luck. I have several columns,
but I need values from checkbox (#3) and Label (#4). I've tried, etc.:
CType(E.Item.FindControl("lblcadatereq"), Label).Text

What is strange is that when I run (Onitemcreated):

Response.Write("value = " & e.Item.Cells(4).Text & "<br>")

I get, there are four rows in my grid (header, two data, a blank bottom
row). I get:
#1 value = "Title of Header"
#2 - 4 value = (is blank). The grid shows data in #2 and #3???

I have also ran a routine to remove the first and last rows using:
e.Item.ItemType = ListItemType.Item Or e.Item.ItemType =
ListItemType.AlternatingItem
but still no values from grid for rows 2 and 3????

Nov 19 '05 #3
I would say that you were on the right track with the OnItemDataBound Event.
This fires before the binding so basically you can grab values from your
datsource and do some conditional logic. OnItemCreated Event also comes to
mind; but somehow I don't think this would give you a solution for this.
They got to have code sames for this out there.
"Chris" <Ch***@discussions.microsoft.com> wrote in message
news:36**********************************@microsof t.com...
I've searched, reviewed, and attempted dozens of code ideas on the
subject. I
can't seem to get something that seems so simple to work. To highlight a
row
in a datagrid based on another value in that row.

I have a datagrid using Template and Item Columns, i.e.:

<asp:TemplateColumn HeaderText="CA Date Req"
HeaderStyle-CssClass="gridqtext" ItemStyle-CssClass="gridtext">
<ItemTemplate>
<asp:Label ID="lblcadatereq" CssClass="gridtext" width="75" Runat="server"
Text='<%# DataBinder.Eval(Container.DataItem, "Concern_DCADate", "{0:d}")
%>'
Visible="True">
</asp:Label>
</ItemTemplate>
</asp:TemplateColumn>

I've tried both Oncreate and OnDataBound, no luck. I have several columns,
but I need values from checkbox (#3) and Label (#4). I've tried, etc.:
CType(E.Item.FindControl("lblcadatereq"), Label).Text

What is strange is that when I run (Onitemcreated):

Response.Write("value = " & e.Item.Cells(4).Text & "<br>")

I get, there are four rows in my grid (header, two data, a blank bottom
row). I get:
#1 value = "Title of Header"
#2 - 4 value = (is blank). The grid shows data in #2 and #3???

I have also ran a routine to remove the first and last rows using:
e.Item.ItemType = ListItemType.Item Or e.Item.ItemType =
ListItemType.AlternatingItem
but still no values from grid for rows 2 and 3????

Nov 19 '05 #4
got it! Was using Itemcreated, switch to ItemDataBound and used:
Dim careq As Boolean = CType(e.Item.Cells(3).FindControl("ckcareq"),
CheckBox).Checked
Dim cadate As Date =
CType(e.Item.Cells(4).FindControl("lblcadatereq"), Label).Text
got the values, thanx.!

"Eliyahu Goldin" wrote:
It is not clear from the message what is your immediate problem. You can't
get a value of a bound column? Bound columns get value in ItemDataBound
event. Also you can use PreRender event in which the grid is already fully
populated with all values.

Eliyahu

"Chris" <Ch***@discussions.microsoft.com> wrote in message
news:36**********************************@microsof t.com...
I've searched, reviewed, and attempted dozens of code ideas on the

subject. I
can't seem to get something that seems so simple to work. To highlight a

row
in a datagrid based on another value in that row.

I have a datagrid using Template and Item Columns, i.e.:

<asp:TemplateColumn HeaderText="CA Date Req"
HeaderStyle-CssClass="gridqtext" ItemStyle-CssClass="gridtext">
<ItemTemplate>
<asp:Label ID="lblcadatereq" CssClass="gridtext" width="75" Runat="server"
Text='<%# DataBinder.Eval(Container.DataItem, "Concern_DCADate", "{0:d}")

%>'
Visible="True">
</asp:Label>
</ItemTemplate>
</asp:TemplateColumn>

I've tried both Oncreate and OnDataBound, no luck. I have several columns,
but I need values from checkbox (#3) and Label (#4). I've tried, etc.:
CType(E.Item.FindControl("lblcadatereq"), Label).Text

What is strange is that when I run (Onitemcreated):

Response.Write("value = " & e.Item.Cells(4).Text & "<br>")

I get, there are four rows in my grid (header, two data, a blank bottom
row). I get:
#1 value = "Title of Header"
#2 - 4 value = (is blank). The grid shows data in #2 and #3???

I have also ran a routine to remove the first and last rows using:
e.Item.ItemType = ListItemType.Item Or e.Item.ItemType =
ListItemType.AlternatingItem
but still no values from grid for rows 2 and 3????


Nov 19 '05 #5

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

Similar topics

1
by: Gerg | last post by:
The datagrid has a tablestyle applied to it, and there are DataGridTextBoxColumn and each DataGridTextBoxColumn has an array of DataGridTextBox objects. Private Sub highlight(ByVal str As...
0
by: Andrea Trevisan | last post by:
That's a revival of a known thing I suppose.I hope it's useful. My problem was: I want to have a DataGrid with two Template columns: first with TextBox,second with Button.I want to fire an event...
4
by: mike | last post by:
I'm trying to highlight a specific row in a datagrid who's contition matches ..text = "Dawn" i've been playing with the code below without much luck, is there a foreach loop i could do, like (...
4
by: Richard Roche | last post by:
Is it possible to use a drop combo instead of a text box when using the EditCommand in the Datagrid? Many table columns are bound to 'lookup' tables, user's don't care about the foreign keys,...
6
by: LU | last post by:
A)I build a datagrid based on a calendar date selection. B)When user clicks a button column on the datagrid I want to highlight this row. I use the code below to highlight the row. ***** CODE...
2
by: Geraldine Hobley | last post by:
Hello I have a datagrid, called MyDataGrid and I wish to put the focus on a particular cell in order that the user to highlight the fact that the user needs to enter a value in this cell, e.g. I put...
0
by: Savvas | last post by:
Hi, I am using VB.Net 2005 for a windows application. The application was actually upgraded from vb.net 2003. I have a search field which is used as a parameter to search all datagrid...
0
by: rn5a | last post by:
How to highlight a row in a DataGrid that has just been edited? EditItemStyle-BackColor will highlight a row when the DataGrid (& a row) is in the editable mode. I want to highlight the row...
1
by: kannabiran | last post by:
Hi Guys, Im using c# asp.net,i had used datagrid to display the record from the database,in the datagrid i had used template column as textbox now i need to highlight the row onmouseover using...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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,...
0
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...
0
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...

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.