473,320 Members | 2,133 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,320 software developers and data experts.

General object type

I want to use the same code for my DataGrid item as I do for my DataList
Item. The only difference is the data type. Is there a generic data type I
can use?

I have a datagrid inside of my data list and want to be able to select
either the dataListItem or the dataGridItem and do exactly the same thing.

For example, instead of:

Dim oDGI as DataGridItem = s.parent.parent
Dim oGrid as DataGrid = oDGI.parent.parent
Dim Answer as Label = CType(oDGI.FindControl("lblAnswer"),Label)
for each oDGI2 as DataGridItem in oGrid.Items

and

Dim oDLI as DataListItem = s.parent.parent
Dim oList as DataGrid = oDLI.parent.parent
Dim Answer as Label = CType(oDLI.FindControl("lblAnswer"),Label)
for each oDLI2 as DataListItem in oList.Items

(which same except for the object names)

Is there a way to do something like:
************************************************** ****
Dim oDI as DataItem ' generic DataItem
Dim oDI2 as DataItem ' generic DataItem
Dim oGridorList as ?
Dim oDLI as DataListItem
Dim oDGI as DataGridItem

if (s.id = "btnGrid") then
Dim oDGI as DataGridItem = s.parent.parent
oDI = oDGI
Dim oGrid as DataGrid = oDGI.parent.parent
oGridorList = oGrid
end if
if (s.id = "btnList") then
oDLI = s.parent.parent
oDI = oDLI
Dim oList as DataList = oDLI.parent.parent
oGridorList = oList
end if

Dim Answer as Label = CType(oDI.FindControl("lblAnswer"),Label)
for each oDI2 as DataItem in oGridorList.Items
************************************************** ******************

Not sure if this can be done, but it would help me to not duplicate my code.

Thanks,

Tom
Nov 19 '05 #1
5 986
> Is there a generic data type I can use?

System.Object?

System.Web.UI.Control?

System.Web.UI.Control.WebControl?

How about System.Web.UI.BaseDataList?

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.

"tshad" <ts**********@ftsolutions.com> wrote in message
news:uG**************@TK2MSFTNGP10.phx.gbl...
I want to use the same code for my DataGrid item as I do for my DataList
Item. The only difference is the data type. Is there a generic data type
I can use?

I have a datagrid inside of my data list and want to be able to select
either the dataListItem or the dataGridItem and do exactly the same thing.

For example, instead of:

Dim oDGI as DataGridItem = s.parent.parent
Dim oGrid as DataGrid = oDGI.parent.parent
Dim Answer as Label = CType(oDGI.FindControl("lblAnswer"),Label)
for each oDGI2 as DataGridItem in oGrid.Items

and

Dim oDLI as DataListItem = s.parent.parent
Dim oList as DataGrid = oDLI.parent.parent
Dim Answer as Label = CType(oDLI.FindControl("lblAnswer"),Label)
for each oDLI2 as DataListItem in oList.Items

(which same except for the object names)

Is there a way to do something like:
************************************************** ****
Dim oDI as DataItem ' generic DataItem
Dim oDI2 as DataItem ' generic
DataItem
Dim oGridorList as ?
Dim oDLI as DataListItem
Dim oDGI as DataGridItem

if (s.id = "btnGrid") then
Dim oDGI as DataGridItem = s.parent.parent
oDI = oDGI
Dim oGrid as DataGrid = oDGI.parent.parent
oGridorList = oGrid
end if
if (s.id = "btnList") then
oDLI = s.parent.parent
oDI = oDLI
Dim oList as DataList = oDLI.parent.parent
oGridorList = oList
end if

Dim Answer as Label = CType(oDI.FindControl("lblAnswer"),Label)
for each oDI2 as DataItem in oGridorList.Items
************************************************** ******************

Not sure if this can be done, but it would help me to not duplicate my
code.

Thanks,

Tom

Nov 19 '05 #2
"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Is there a generic data type I can use?
System.Object?

System.Web.UI.Control?

System.Web.UI.Control.WebControl?

How about System.Web.UI.BaseDataList?


I know about those.

But how about below where I am trying to use one variable for both a
DataListItem and DataGridItem pointer? As well as a pointer to DataGrid and
a DataList. I would mainly need this to use the FindControl method as well
as in my "for each oDI2 as DataItem in oGridorList.Items".

Tom

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
What You Seek Is What You Get.

"tshad" <ts**********@ftsolutions.com> wrote in message
news:uG**************@TK2MSFTNGP10.phx.gbl...
I want to use the same code for my DataGrid item as I do for my DataList
Item. The only difference is the data type. Is there a generic data type
I can use?

I have a datagrid inside of my data list and want to be able to select
either the dataListItem or the dataGridItem and do exactly the same
thing.

For example, instead of:

Dim oDGI as DataGridItem = s.parent.parent
Dim oGrid as DataGrid = oDGI.parent.parent
Dim Answer as Label = CType(oDGI.FindControl("lblAnswer"),Label)
for each oDGI2 as DataGridItem in oGrid.Items

and

Dim oDLI as DataListItem = s.parent.parent
Dim oList as DataGrid = oDLI.parent.parent
Dim Answer as Label = CType(oDLI.FindControl("lblAnswer"),Label)
for each oDLI2 as DataListItem in oList.Items

(which same except for the object names)

Is there a way to do something like:
************************************************** ****
Dim oDI as DataItem ' generic
DataItem
Dim oDI2 as DataItem ' generic
DataItem
Dim oGridorList as ?
Dim oDLI as DataListItem
Dim oDGI as DataGridItem

if (s.id = "btnGrid") then
Dim oDGI as DataGridItem = s.parent.parent
oDI = oDGI
Dim oGrid as DataGrid = oDGI.parent.parent
oGridorList = oGrid
end if
if (s.id = "btnList") then
oDLI = s.parent.parent
oDI = oDLI
Dim oList as DataList = oDLI.parent.parent
oGridorList = oList
end if

Dim Answer as Label = CType(oDI.FindControl("lblAnswer"),Label)
for each oDI2 as DataItem in oGridorList.Items
************************************************** ******************

Not sure if this can be done, but it would help me to not duplicate my
code.

Thanks,

Tom


Nov 19 '05 #3
Well, Tom, seeing as how I would have to look all that stuff up (no, I've
never tried to do what you want to do), how about I just send you to the
place I would look?

http://msdn.microsoft.com/library/de...classtopic.asp

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.

"tshad" <ts**********@ftsolutions.com> wrote in message
news:eY**************@TK2MSFTNGP10.phx.gbl...
"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Is there a generic data type I can use?


System.Object?

System.Web.UI.Control?

System.Web.UI.Control.WebControl?

How about System.Web.UI.BaseDataList?


I know about those.

But how about below where I am trying to use one variable for both a
DataListItem and DataGridItem pointer? As well as a pointer to DataGrid
and a DataList. I would mainly need this to use the FindControl method as
well as in my "for each oDI2 as DataItem in oGridorList.Items".

Tom

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
What You Seek Is What You Get.

"tshad" <ts**********@ftsolutions.com> wrote in message
news:uG**************@TK2MSFTNGP10.phx.gbl...
I want to use the same code for my DataGrid item as I do for my DataList
Item. The only difference is the data type. Is there a generic data
type I can use?

I have a datagrid inside of my data list and want to be able to select
either the dataListItem or the dataGridItem and do exactly the same
thing.

For example, instead of:

Dim oDGI as DataGridItem = s.parent.parent
Dim oGrid as DataGrid = oDGI.parent.parent
Dim Answer as Label = CType(oDGI.FindControl("lblAnswer"),Label)
for each oDGI2 as DataGridItem in oGrid.Items

and

Dim oDLI as DataListItem = s.parent.parent
Dim oList as DataGrid = oDLI.parent.parent
Dim Answer as Label = CType(oDLI.FindControl("lblAnswer"),Label)
for each oDLI2 as DataListItem in oList.Items

(which same except for the object names)

Is there a way to do something like:
************************************************** ****
Dim oDI as DataItem ' generic
DataItem
Dim oDI2 as DataItem ' generic
DataItem
Dim oGridorList as ?
Dim oDLI as DataListItem
Dim oDGI as DataGridItem

if (s.id = "btnGrid") then
Dim oDGI as DataGridItem = s.parent.parent
oDI = oDGI
Dim oGrid as DataGrid = oDGI.parent.parent
oGridorList = oGrid
end if
if (s.id = "btnList") then
oDLI = s.parent.parent
oDI = oDLI
Dim oList as DataList = oDLI.parent.parent
oGridorList = oList
end if

Dim Answer as Label = CType(oDI.FindControl("lblAnswer"),Label)
for each oDI2 as DataItem in oGridorList.Items
************************************************** ******************

Not sure if this can be done, but it would help me to not duplicate my
code.

Thanks,

Tom



Nov 19 '05 #4
"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:Os**************@TK2MSFTNGP10.phx.gbl...
Well, Tom, seeing as how I would have to look all that stuff up (no, I've
never tried to do what you want to do), how about I just send you to the
place I would look?
I read it but not sure if I will be able to use it or not - will try it and
see.

I didn't realize that both came from BaseDataList ( I assumed the datagrid
from come from something like BaseDataGrid).

Thanks,

Tom
http://msdn.microsoft.com/library/de...classtopic.asp

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
What You Seek Is What You Get.

"tshad" <ts**********@ftsolutions.com> wrote in message
news:eY**************@TK2MSFTNGP10.phx.gbl...
"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Is there a generic data type I can use?

System.Object?

System.Web.UI.Control?

System.Web.UI.Control.WebControl?

How about System.Web.UI.BaseDataList?


I know about those.

But how about below where I am trying to use one variable for both a
DataListItem and DataGridItem pointer? As well as a pointer to DataGrid
and a DataList. I would mainly need this to use the FindControl method
as well as in my "for each oDI2 as DataItem in oGridorList.Items".

Tom

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
What You Seek Is What You Get.

"tshad" <ts**********@ftsolutions.com> wrote in message
news:uG**************@TK2MSFTNGP10.phx.gbl...
I want to use the same code for my DataGrid item as I do for my DataList
Item. The only difference is the data type. Is there a generic data
type I can use?

I have a datagrid inside of my data list and want to be able to select
either the dataListItem or the dataGridItem and do exactly the same
thing.

For example, instead of:

Dim oDGI as DataGridItem = s.parent.parent
Dim oGrid as DataGrid = oDGI.parent.parent
Dim Answer as Label = CType(oDGI.FindControl("lblAnswer"),Label)
for each oDGI2 as DataGridItem in oGrid.Items

and

Dim oDLI as DataListItem = s.parent.parent
Dim oList as DataGrid = oDLI.parent.parent
Dim Answer as Label = CType(oDLI.FindControl("lblAnswer"),Label)
for each oDLI2 as DataListItem in oList.Items

(which same except for the object names)

Is there a way to do something like:
************************************************** ****
Dim oDI as DataItem ' generic
DataItem
Dim oDI2 as DataItem ' generic
DataItem
Dim oGridorList as ?
Dim oDLI as DataListItem
Dim oDGI as DataGridItem

if (s.id = "btnGrid") then
Dim oDGI as DataGridItem = s.parent.parent
oDI = oDGI
Dim oGrid as DataGrid = oDGI.parent.parent
oGridorList = oGrid
end if
if (s.id = "btnList") then
oDLI = s.parent.parent
oDI = oDLI
Dim oList as DataList = oDLI.parent.parent
oGridorList = oList
end if

Dim Answer as Label = CType(oDI.FindControl("lblAnswer"),Label)
for each oDI2 as DataItem in oGridorList.Items
************************************************** ******************

Not sure if this can be done, but it would help me to not duplicate my
code.

Thanks,

Tom



Nov 19 '05 #5
> I didn't realize that both came from BaseDataList ( I assumed the
datagrid from come from something like BaseDataGrid).
That's why I included it in my list! :)

The list is a lit of all the classes that both classes inherit.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.

"tshad" <ts**********@ftsolutions.com> wrote in message
news:ey**************@TK2MSFTNGP14.phx.gbl... "Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:Os**************@TK2MSFTNGP10.phx.gbl...
Well, Tom, seeing as how I would have to look all that stuff up (no, I've
never tried to do what you want to do), how about I just send you to the
place I would look?


I read it but not sure if I will be able to use it or not - will try it
and see.

I didn't realize that both came from BaseDataList ( I assumed the
datagrid from come from something like BaseDataGrid).

Thanks,

Tom

http://msdn.microsoft.com/library/de...classtopic.asp

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
What You Seek Is What You Get.

"tshad" <ts**********@ftsolutions.com> wrote in message
news:eY**************@TK2MSFTNGP10.phx.gbl...
"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
> Is there a generic data type I can use?

System.Object?

System.Web.UI.Control?

System.Web.UI.Control.WebControl?

How about System.Web.UI.BaseDataList?

I know about those.

But how about below where I am trying to use one variable for both a
DataListItem and DataGridItem pointer? As well as a pointer to DataGrid
and a DataList. I would mainly need this to use the FindControl method
as well as in my "for each oDI2 as DataItem in oGridorList.Items".

Tom
--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
What You Seek Is What You Get.

"tshad" <ts**********@ftsolutions.com> wrote in message
news:uG**************@TK2MSFTNGP10.phx.gbl...
>I want to use the same code for my DataGrid item as I do for my
>DataList Item. The only difference is the data type. Is there a
>generic data type I can use?
>
> I have a datagrid inside of my data list and want to be able to select
> either the dataListItem or the dataGridItem and do exactly the same
> thing.
>
> For example, instead of:
>
> Dim oDGI as DataGridItem = s.parent.parent
> Dim oGrid as DataGrid = oDGI.parent.parent
> Dim Answer as Label = CType(oDGI.FindControl("lblAnswer"),Label)
> for each oDGI2 as DataGridItem in oGrid.Items
>
> and
>
> Dim oDLI as DataListItem = s.parent.parent
> Dim oList as DataGrid = oDLI.parent.parent
> Dim Answer as Label = CType(oDLI.FindControl("lblAnswer"),Label)
> for each oDLI2 as DataListItem in oList.Items
>
> (which same except for the object names)
>
> Is there a way to do something like:
> ************************************************** ****
> Dim oDI as DataItem ' generic
> DataItem
> Dim oDI2 as DataItem ' generic
> DataItem
> Dim oGridorList as ?
> Dim oDLI as DataListItem
> Dim oDGI as DataGridItem
>
> if (s.id = "btnGrid") then
> Dim oDGI as DataGridItem = s.parent.parent
> oDI = oDGI
> Dim oGrid as DataGrid = oDGI.parent.parent
> oGridorList = oGrid
> end if
>
>
> if (s.id = "btnList") then
> oDLI = s.parent.parent
> oDI = oDLI
> Dim oList as DataList = oDLI.parent.parent
> oGridorList = oList
> end if
>
> Dim Answer as Label = CType(oDI.FindControl("lblAnswer"),Label)
> for each oDI2 as DataItem in oGridorList.Items
> ************************************************** ******************
>
> Not sure if this can be done, but it would help me to not duplicate my
> code.
>
> Thanks,
>
> Tom
>
>



Nov 19 '05 #6

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

Similar topics

20
by: syd | last post by:
In my project, I've got dozens of similar classes with hundreds of description variables in each. In my illustrative example below, I have a Library class that contains a list of Nation classes. ...
21
by: AnnMarie | last post by:
<script language="JavaScript" type="text/javascript"> <!-- function validate(theForm) { var validity = true; // assume valid if(frmComments.name.value=='' && validity == true) { alert('Your...
2
by: Ross Micheals | last post by:
All I have some general .NET questions that I'm looking for some help with. Some of these questions (like the first) are ones that I've seen various conflicting information on, or questions that...
39
by: Antoon Pardon | last post by:
I was wondering how people would feel if the cmp function and the __cmp__ method would be a bit more generalised. The problem now is that the cmp protocol has no way to indicate two objects are...
9
by: pankaj_wolfhunter | last post by:
Hi, I need some clearance on the following questions: 1) Does LOAD command updates indexes defined for a table? 2) Is REPLACE option in the LOAD command a logged operation? Help will be...
13
by: gmccallum | last post by:
General Info: A struct is stored on the stack and a class on the heap. A struct is a value type while a class is a reference type. Question: What if a struct contains a string...
5
by: Mac via DotNetMonster.com | last post by:
Hi all, I have a creating a my own tabpage class (MyTabPage) which inherits the .Net TabPage class. In the relevant event I want to loop through the collection of TabPages and then when I...
105
by: Christoph Zwerschke | last post by:
Sometimes I find myself stumbling over Python issues which have to do with what I perceive as a lack of orthogonality. For instance, I just wanted to use the index() method on a tuple which does...
6
by: djc | last post by:
I had previously (in asp.net 1.1 and asp.net web matrix) just done this to populate a listbox with data from a database: ------------ this was from the page load event ---------------- 'fill...
16
by: PeterAPIIT | last post by:
Hello all C++ expert programmer, i have wrote partial general allocator for my container. After reading standard C++ library and code guru article, i have several questions. 1. Why...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.