473,382 Members | 1,745 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,382 software developers and data experts.

"is" operator doesn't evaluate correctly while performing databind

Hi

Ive got a custom collection of class which I use as the data source for a
DataGrid control.

I execute the following code prior to beginning my data binding:

if (list_[0] is BatchWorkItem) { ....} // do stuff

This evaluates to true.

I then execute the DataBind() method for the datagrid. In my handler for
ItemDataBound. Within the event handler I execute the same code, however this
time is evaluates to false.

After the DataBinding is complete, I again execute that expression and it
evalutes to true.

During this time I don't perform any operations of the datasource, nor the
contents.

The full code listing is as follow:

In Page Load (Not post back condition)

if (listSource_[0] is BatchWorkListItem) {
// compiler steps in
}

// populate the data grid.
populateGrid();

if (listSource_[0] is BatchWorkListItem) {
// compiler steps in
}

The following are the handler method(s)

private void populateGrid() {
workListGrid.DataSource = listSource_;
workListGrid.DataKeyField = "ID"; // Property of BatchWorkListItem
workListGrid.DataBind();
}

private void workListGrid_ItemDataBound(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e) {
// check what type and activity the work list items is for the
// navigation URL

switch (e.Item.ItemType) {
case ListItemType.AlternatingItem :
// force a fall-through.
goto case ListItemType.Item;
case ListItemType.Item :
resolveProceedUrl(e.Item.ItemIndex);
break;
}
}

private void resolveProceedUrl(int index) {
// hard coded index for debugging purpose
if (listSource_[0] is BatchWorkListItem) {
// compiler doesn't step in here
}
}

When I add watches to the datasource, I don't see any changes on the
contents during the binding process.

Thanks in advance for the assistance..
Nov 17 '05 #1
0 1044

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

Similar topics

15
by: Bobby C. Jones | last post by:
Is there an advantage to either of these methods, or is it simply a matter of style? I used to use the "as" method, but later gave it up for the "is" method as the intent of the code seems a...
6
by: Derrick | last post by:
Hello all; Since I do have working code, this is more for my curiosity only. I'm creating a "Plugin" architecture, following some of the many examples on the 'net. Basically what I have is...
2
by: mark | last post by:
How do I detect that a particular form element is a file upload or if the file upload has worked? In the Python cgi module documentation I found suggested code... form = cgi.FieldStorage()...
3
by: JimM | last post by:
I am trying to create a method in VS 2003 that validates an object argument is of the proper type and within a range of values. I am trying to use a Type to define the casting and object type for...
9
by: Lonnie Princehouse | last post by:
There doesn't seem to be any way to customize the behavior of "is" as can be done for other operators... why not?
4
by: Johndow | last post by:
I have trouble to use "Is" operator to a type that is from reflection. Basically, here is what I want to do, if Class1 type is not from reflection: class Class1 { } public class Test { ... if...
17
by: nicolas.hilaire | last post by:
Hi all, i've read this article http://msdn2.microsoft.com/en-us/library/85af44e9.aspx who first interest me much. I've translated it to use generic instead of template : generic < typename ...
4
by: Tina | last post by:
This is an issue regarding what exactly is accomplished by using "Protected" when defining a variable. It seems it does much more than just applying Protected status to a variable. I have an...
81
by: BlueJ774 | last post by:
Can someone please explain to me the difference between the "is" keyword and the == boolean operator. I can't figure it out on my own and I can't find any documentation on it. I can't...
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.