Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx_professional thread: Dataset or DataReader ?


Message #1 by nahid.mohammadi@b... on Mon, 3 Jun 2002 20:17:06
Chuck

 Thank you so much. You always give us great tips and advices. Please keep
it up. 

 Nahid

-----Original Message-----
From: Feduke Cntr Charles R [mailto:FedukeCR@m...]
Sent: Tuesday, June 04, 2002 7:35 AM
To: ASPX_Professional
Subject: [aspx_professional] RE: Dataset or DataReader ?


Nahid,

> and that is the "itemType". All my items in the datagrid are "string"
type.

	Yes, you can still do what you want to do with the code I
illustrated below.  I was pointing you to the event and what items to catch;
at the point in the code where you see

---
// your code to change background color here, i.e.
		((TableCell)e.Item.Controls[0]).BackgroundColor 
			Color.Ivory;
		// something like that, above
---

you could do all manner of tests, to include testing the text value of the
cell:

TableCell tc = (TableCell)e.Item;
if (e.Text.Equals("OUT"))
	e.BackgroundColor = Color.Red;
if (e.Text.Equals("IN"))
	e.BackgroundColor = Color.Green;
// etc etc

	I was checking for ItemType in the code below because you only want
your text comparison logic to fire when the item that is being created is a
Item or AlternatingItem (and I put in EditItem, but you would need special
logic to handle that because the TableCell won't have any text, but
tc.Controls[0] (being a TextBox or whatnot) might).

HTH,
- Chuck

-----Original Message-----
From: Mohammadi, Nahid [mailto:Nahid.Mohammadi@B...]
Sent: Monday, June 03, 2002 5:02 PM
To: 'FedukeCR@m...'
Subject: RE: [aspx_professional] RE: Dataset or DataReader ?


Chuck

 I really appreciate for your solution. But, there is one point in your code
and that is the "itemType". All my items in the datagrid are "string" type.
I need to compare with content of the grid and not the type of the content. 
Like 
  if (item.text == "ABC" then
 ((TableCell)e.Item.Controls[0]).BackgroundColor 
Color.Ivory;


  
here is the screen shot of my application that I have develop it by
PowerBuilder. 
As you see I have a pretty colorful table and I like create such a thing as
a web application. 

Do you think such a thing is possible?
 I am sure you have some idea and I appreciate if you share it with me.
anything will help since I am not an expert like you :)

 Thanks 

 Nahid 
-----Original Message-----
From: Feduke Cntr Charles R [mailto:FedukeCR@m...]
Sent: Monday, June 03, 2002 2:39 PM
To: ASPX_Professional
Subject: [aspx_professional] RE: Dataset or DataReader ?


Nahid,

General & 1.	Does your page _refresh_ every 60 seconds, or do you need a
component that fires some event that causes the dataset to be updated every
60 seconds?  Personally I would use a DataReader because its light-weight,
read-only, similiar to ADO's firehose cursor.  Whenever you're doing
modifications to the underlying database, execute the SQL statement with a
Command object; of course if your page is refreshing every 60 seconds a user
could be in the middle of an edit and ::pop:: it refreshes on them.

3. You can write your own event for the OnItemCreated and if the type of the
item being created is Item or EditItem or AlternatingItem, then check the
data and color the background.

protected void ItemCreated(Object sender, DataGridItemEventArgs e)
{
	ListItemType itemType = e.Item.ItemType;
	if (itemType == ListItemType.Item ||
		itemType == ListItemType.EditItem ||
		itemType == ListItemType.AlternatingItem)
	{
		// your code to change background color here, i.e.
		((TableCell)e.Item.Controls[0]).BackgroundColor 
Color.Ivory;
		// something like that, above
	}
}

// in OnInit (assuming your DataGrid is named "dg" in this example
dg.ItemCreated = new DataGridItemEventHandler(this.ItemCreated);

HTH,
- Chuck

-----Original Message-----
From: nahid.mohammadi@b... [mailto:nahid.mohammadi@b...]
Sent: Monday, June 03, 2002 4:17 PM
To: ASPX_Professional
Subject: [aspx_professional] Dataset or DataReader ?


I am plannin for an application that need to read from database every 60 
second, and Sometimes it need to modify to update soem data in the 
datbase.I have some question about teh component that I may need to use in 
this application. 

1- What data control I need to use, a DataReader or a DataSet? I think I 
should I use DataSet but for every second updateing the page, there is too 
much overhead that involves with DataSet. 

2- How can I create a TabControl in my web padge. I tried to get some help 
with some pre-built tabpages but they did not work for me.

3- The backgroung color of the datagrid celles needs to be change with 
repect to the data that it has( not the type of the data). How can I do 
this. 

I surly appreciate any information. 

Nahid

  




  Return to Index