Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Updatecommand with Datagrid problem 1

Status
Not open for further replies.

lanm

Programmer
Jul 7, 2005
244
US
I'm using the first data column's EditItem Template to allow the user to edit 6 fields. This has allowed us to get the datagrid to expand vertically and increase the font size too. I'm using an HTML table control to hold the text boxes and dropdownlists so it's structured, but now...on the UpdateCommand, I can't get the cast correct and/or find the control to get the associated data for the Update statement. The error and line are:
"Specified Cast is not valid"

txtType = CType(e.Item.Cells(4).Controls(2), TextBox).Text

Can/should I even use an HTML control to hold the items in the EditItem template?

Any suggestions are welcome!
 
You appear to be setting a TextBox (I'm assuming that is what it is as it is prefixed txt) to the Text property of a TextBox and this may be where the error is (i.e. you can't set a TextBox to equal a String).


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Thanks ca8msm!

I just had to do:
txtType = CType(e.Item.Cells(4).Controls(2), TextBox).Text.ToString()

...and it worked.

 
now, I get an error on the line of code:

Dim ddlP3ResCode As DropDownList = CType(e.Item.Cells(4).Controls(7), DropDownList)


This is the third row / second column of the HTML table.
I have the first dropdownlist working correctly, which is the first row / second column, and it's line of code is:
Dim ddlName As DropDownList = CType(e.Item.Cells(4).Controls(3), DropDownList)

Does the tab index not make a different when using the integer parameter for the Controls( )?

Any suggestions are welcome! Any way to find out where this "problem" ddl is?
 
Could you use FindControl to get a handle on the control instead?


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
I'll try that!

Thanks so much for the help! I'm getting closer with this whole thing!
 
ca8msm,

That's doing the trick....using FindControl()!
Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top