473,473 Members | 2,008 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Cast Error from control in DataGrid cell

Hi,

I am having a problem with the following line of code:

oDR("UIGroupTypeID") = CType(e.Item.Cells(3).Controls(0),
DropDownList).SelectedValue

The error I get is the Cast is not valid.

Any ideas?

I have tried to get the actual type at runtime just before the error occurs
with this line of code:
Dim s As String =
e.Item.Cells(3).Controls(0).GetType.UnderlyingSyst emType.ToString

The value of s is System.Web.UI.LiteralControl

Thanks,

Chris Lane
Nov 21 '05 #1
2 997
Is there a way I can get the index or column that the control is in by it's
name?
Nov 21 '05 #2
Looks like this code that is based off of a codesmith template that someone
shared is wrong when it references the controls index within the datagrid
column.

"Chris Lane" wrote:
Hi,

I am having a problem with the following line of code:

oDR("UIGroupTypeID") = CType(e.Item.Cells(3).Controls(0),
DropDownList).SelectedValue

The error I get is the Cast is not valid.

Any ideas?

I have tried to get the actual type at runtime just before the error occurs
with this line of code:
Dim s As String =
e.Item.Cells(3).Controls(0).GetType.UnderlyingSyst emType.ToString

The value of s is System.Web.UI.LiteralControl

Thanks,

Chris Lane

Nov 21 '05 #3

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

Similar topics

2
by: Dave Leach | last post by:
I am writing a Windows MDI application in C#. I would like to cast an object to a specific type. I know that the object is of a compatible type. The code below shows what I would like to do, but...
2
by: Tolga | last post by:
How do insert a user control i have created into a datagrid cell. Basically i am trying to create a column of my user controls. This is what i have tried so far. int i = 0; while (i <...
0
by: Alan Z. Scharf | last post by:
Win Server 2003 VS.Net 2003 --------------- 1. I'm having the same problem below on all six of my pages with a datagrid item. 2. These pages all worked fine for months until problem started....
15
by: David | last post by:
Hi, I have built a web application that will be a very high profile application. We had tested it, demonstrated it and shown that it all works. On a dress rehearsal run through, it failed...
2
by: Fabrice | last post by:
Hello, First, thanks to felix for his answer. But :-( , I'm feeling newbie :! I' don't understand all the situation. The trouble : Always in the road whith my Datagrid and my ItemTemplate...
3
by: chreo | last post by:
Hello. I have datagrid. I found code to select all row in data grid (by mouse or arrow keys). This works great - user can select row and... ....and I want to go to next control. For...
4
by: Alan | last post by:
I keep getting an invalid cast error on this line of code: Dim gridCol As MyGridColumn = CType(dgt.GridColumnStyles(hi.Column), MyGridColumn) I am trying to develop a sub that will change the...
2
by: tshad | last post by:
I have an ItemDataBound event for my delete button and am getting an error: System.InvalidCastException: Specified cast is not valid. The event code: ...
2
by: jock1up | last post by:
I am working with editing within a DataGrid control cell and am confused about which events occur after the editing is completed. I see that 5 events can occur total, including the ones below and...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.