Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > Modify rows in DataTable

Reply
Thread Tools

Modify rows in DataTable

 
 
Elton Wang
Guest
Posts: n/a
 
      03-07-2005
Hi Steve,

Suppose you want to change text in some column depending
on the data in data source, you can do it in ItemDataBound
event.

Dim itemType As ListItemType = e.Item.ItemType
If itemType = ListItemType.AlternatingItem OrElse itemType
= ListItemType.Item Then
' Get data from underlying data source
Dim drv As DataRowView = CType(e.Item.DataItem,
DataRowView)
Dim cell As TableCell = e.Item.Cells(colIndex)
If drv(colindex) = (today's event) Then
cell.Text = "Today"
cell.BackColor = Color.Red
End If
End If

The ItemDataBound will automatically loop thru whole rows

HTH

Elton Wang
elton_wang_hotmail.com

>-----Original Message-----
>ASP.NET 1.1, Web Forms :
>In my code I create a DataSet, then a DataTable within it.
>I want to loop through the rows of the DataTable and

modify the columns of each row.
>
>For example, I create a table that gets bound to a

DataGrid, to show upcoming events form my club. If the
event is today, I want to alter the text to say "Today!"
and change the color.
>
>I figure that I can resort to the old "Response.Write"

loop via old ASP, but am new to ASP.NET and want to learn
the "right" way.
>
>Thanks in advance
>--------------------------------
>From: Steve Delia
>
>-----------------------
>Posted by a user from .NET 247 (http://www.dotnet247.com/)
>
><Id>4BusL5JNJkGm8kr2ZUyaYg==</Id>
>.
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sort a datatable and create a new datatable Fredrik Rodin ASP .Net 3 09-28-2007 07:28 AM
How can I add a row from a typed datatable to another instance of that typed datatable? Ersin Gençtürk ASP .Net 1 10-06-2004 01:11 PM
Create a Datatable from a SQL datatable column shema? jg ASP .Net 1 08-17-2004 09:43 PM
Casting DataTable to class inherit from DataTable =?Utf-8?B?Qmx1ZWZsb3dlcg==?= ASP .Net 0 04-02-2004 05:41 AM
Adding DataTable Rows To another DataTable J. Babe ASP .Net 1 08-15-2003 05:04 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57