Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > how to get to the underlying data in a datagrid control?

Reply
Thread Tools

how to get to the underlying data in a datagrid control?

 
 
djc
Guest
Posts: n/a
 
      12-16-2004
How do I get to the underlying data in a databound datagrid control? I have
tried several different things all with no luck. I know you should be able
to get to the data.... how exactly? The following is the last thing I tried
and I get this error: "Name 'Container' is not declared". Another thing I
tried is like below only I used e.DataItem instead of Container.DataItem and
in that case I got an error indicating that 'DataItem' was not a valid
property of 'e', or something to that effect.

Sub OnItemDataBound_Handler(sender As Object, e As DataGridItemEventArgs)
Dim itemType As ListItemType = e.Item.ItemType
If itemType = ListItemType.Item Or itemType =
ListItemType.AlternatingItem Then
If Not DataBinder.Eval(Container.DataItem,
"EstimatedDeliveryDate") Is DbNull.Value Then

Dim TheETA As DateTime =
DateValue(DataBinder.Eval(Container.DataItem("Esti matedDeliveryDate")))
Dim TheStatus As String =
DataBinder.Eval(Container.DataItem("Status")).ToSt ring()

If (TheETA < Today) And (TheStatus = "In Progress") Then
e.Item.Cells(4).CssClass = "ETAColumnStyle_Overdue"
End If

End If
End If
End Sub

any help would be greatly appreciated.
thanks.


 
Reply With Quote
 
 
 
 
Elton Wang
Guest
Posts: n/a
 
      12-17-2004
Following code snippet shows how to get data:

DataRowView drv = (DataRowView)e.Item.DataItem;
TableCell cell = (TableCell)e.Item.Controls[columnIndex];
cell.Text = drv[columnIndex].Tostring().Substring(0,
length);

Dim drv As DataRowView = CType(e.Item.DataItem,
DataRowView)
Dim TheETA As DateTime = CType(drv
("EstimatedDeliveryDate"), DateTime)
Dim TheStatus As String = drv("Status").ToString


Elton Wang

http://www.velocityreviews.com/forums/(E-Mail Removed)

>-----Original Message-----
>How do I get to the underlying data in a databound

datagrid control? I have
>tried several different things all with no luck. I know

you should be able
>to get to the data.... how exactly? The following is the

last thing I tried
>and I get this error: "Name 'Container' is not declared".

Another thing I
>tried is like below only I used e.DataItem instead of

Container.DataItem and
>in that case I got an error indicating that 'DataItem'

was not a valid
>property of 'e', or something to that effect.
>
>Sub OnItemDataBound_Handler(sender As Object, e As

DataGridItemEventArgs)
> Dim itemType As ListItemType = e.Item.ItemType
> If itemType = ListItemType.Item Or itemType =
>ListItemType.AlternatingItem Then
> If Not DataBinder.Eval(Container.DataItem,
>"EstimatedDeliveryDate") Is DbNull.Value Then
>
> Dim TheETA As DateTime =
>DateValue(DataBinder.Eval(Container.DataItem

("EstimatedDeliveryDate")))
> Dim TheStatus As String =
>DataBinder.Eval(Container.DataItem("Status")).ToS tring()
>
> If (TheETA < Today) And (TheStatus = "In

Progress") Then
> e.Item.Cells(4).CssClass

= "ETAColumnStyle_Overdue"
> End If
>
> End If
> End If
> End Sub
>
>any help would be greatly appreciated.
>thanks.
>
>
>.
>

 
Reply With Quote
 
 
 
 
djc
Guest
Posts: n/a
 
      12-17-2004
THANK YOU THANK YOU THANK YOU!!!!!

"Elton Wang" <(E-Mail Removed)> wrote in message
news:102601c4e3cb$ed50fab0$(E-Mail Removed)...
> Following code snippet shows how to get data:
>
> DataRowView drv = (DataRowView)e.Item.DataItem;
> TableCell cell = (TableCell)e.Item.Controls[columnIndex];
> cell.Text = drv[columnIndex].Tostring().Substring(0,
> length);
>
> Dim drv As DataRowView = CType(e.Item.DataItem,
> DataRowView)
> Dim TheETA As DateTime = CType(drv
> ("EstimatedDeliveryDate"), DateTime)
> Dim TheStatus As String = drv("Status").ToString
>
>
> Elton Wang
>
> (E-Mail Removed)
>
> >-----Original Message-----
> >How do I get to the underlying data in a databound

> datagrid control? I have
> >tried several different things all with no luck. I know

> you should be able
> >to get to the data.... how exactly? The following is the

> last thing I tried
> >and I get this error: "Name 'Container' is not declared".

> Another thing I
> >tried is like below only I used e.DataItem instead of

> Container.DataItem and
> >in that case I got an error indicating that 'DataItem'

> was not a valid
> >property of 'e', or something to that effect.
> >
> >Sub OnItemDataBound_Handler(sender As Object, e As

> DataGridItemEventArgs)
> > Dim itemType As ListItemType = e.Item.ItemType
> > If itemType = ListItemType.Item Or itemType =
> >ListItemType.AlternatingItem Then
> > If Not DataBinder.Eval(Container.DataItem,
> >"EstimatedDeliveryDate") Is DbNull.Value Then
> >
> > Dim TheETA As DateTime =
> >DateValue(DataBinder.Eval(Container.DataItem

> ("EstimatedDeliveryDate")))
> > Dim TheStatus As String =
> >DataBinder.Eval(Container.DataItem("Status")).ToS tring()
> >
> > If (TheETA < Today) And (TheStatus = "In

> Progress") Then
> > e.Item.Cells(4).CssClass

> = "ETAColumnStyle_Overdue"
> > End If
> >
> > End If
> > End If
> > End Sub
> >
> >any help would be greatly appreciated.
> >thanks.
> >
> >
> >.
> >



 
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
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
How to get more data from a gridview's underlying datasource? Curious Trigger ASP .Net 4 07-24-2006 06:17 PM
How to get underlying data of TreeView control? (ASP.NET 2.0) placek ASP .Net Web Controls 6 03-30-2006 10:04 AM
ObjectDataSource's underlying data/schema =?Utf-8?B?RGljaw==?= ASP .Net 2 03-01-2006 08:26 AM
How do I use two different class interfaces to the same underlying data? velthuijsen C++ 2 11-18-2004 08:03 AM



Advertisments