michael5865
asked on
I am having trouble with data types
I am coding the UpdateCommand of a DataGrid in a VB.NET Webform.
I am having trouble with data types.
Specifically, the following statement works fine except that I don't want to read Cells(5).
Dim ModelIDText As TextBox = CType(e.Item.Cells(5).Cont rols(0), TextBox)
When I replace Cells(5) with Cells(1), I get the following error:
[InvalidCastException: Specified cast is not valid.]
Cells(5) in my datagrid is type string
Cells(1) in my datagrid is type integer
How do I get ModelID to have the integer value of Cells(1)?
Thanks
Michael
I am having trouble with data types.
Specifically, the following statement works fine except that I don't want to read Cells(5).
Dim ModelIDText As TextBox = CType(e.Item.Cells(5).Cont
When I replace Cells(5) with Cells(1), I get the following error:
[InvalidCastException: Specified cast is not valid.]
Cells(5) in my datagrid is type string
Cells(1) in my datagrid is type integer
How do I get ModelID to have the integer value of Cells(1)?
Thanks
Michael
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Right Click on the Datagrid, select Property Builder (I think that is the option - do not have .NET on this PC), then select column Builder.
Click on the first two columns listed (one at a time), and UNCHECK the Visible checkbox.
Those tow columns will then NOT be Visible, but will be present, and you can then get the value, as I indicated, earlier.
AW
Click on the first two columns listed (one at a time), and UNCHECK the Visible checkbox.
Those tow columns will then NOT be Visible, but will be present, and you can then get the value, as I indicated, earlier.
AW
ASKER
To get it to work correctly, I had to make "visible" two coloums that are used as identifiers.
I believe I can set these column widths to zero so that in practice they are not visible.
I tried to do this in the properties of the datagrid but it didn't seem to make them dissappear. Can you tell me how to make two colums of a datagrid (that are required for the code but not for the user) - invisible?
Thanks,
Michael