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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing values Thru codebehind. 2

Status
Not open for further replies.

qwert231

Programmer
Sep 4, 2001
756
US
K, I'm not sure where to head with this, so looking for pointers.

I have a form, a button clicks and the codebehind event fires... this codebehind calls a function from a module that will work with data on the form. How do I pass the info from the form to this module, or how can I tell the module to get the data from the form.

In codebehind I can get away with Request.Form("elementName") but this doesn't work in the module. Thanks.
 
current.request.form("fieldName")

should work inside the module, assuming your import

system.web.httpContext
penny1.gif
penny1.gif
 
K, how bout if those controls are in a Datagrid? ;)
 
you need to get em out.
set a datagridItem to the grid row you want then do something like the following

dim t as textbox = Ctype(dgItem.Cells(1).Controls(0), textbox)

then send t in. That'l do donkey, that'l do
[bravo] Mark
If you are unsure of forum etiquette check here faq796-2540
 
Hmmm... thinking about that. I don't know if I can quite visualize that. Also, if I specify ids for the controls can I do something like dg.Item.cells(0).controls("specificID")?
 
Should be able to yes. Don't forget to specify which item.
Item is synonomous with row That'l do donkey, that'l do
[bravo] Mark
If you are unsure of forum etiquette check here faq796-2540
 
K, so I do this:
Code:
Dim _item As DataGridItem = jobInfoDG.Items(0)
strSQL += "A=" & _item.Cells(0).Controls("Pack1")

but it says I cannot concatenate them.
 
U didn't follow the code I gave you. Your trying to concatenate a string and a control of unknown type. You know that control 0 is a text box so cast it like I have in the example above.

Then use the casted textbox to get the value using the .text property That'l do donkey, that'l do
[bravo] Mark
If you are unsure of forum etiquette check here faq796-2540
 
Okay, so maybe I'm not following you... I want the contents of the control to be added to a String. There will be various types of controls I am going to do this with. I tried it the way you mentioned above like this:
Code:
strSQL = "UPDATE tblOrderDetails Set "
Dim t As TextBox = CType(_item.Cells(0).Controls("Pack1"), TextBox)
strSQL += "A=" & t
(for brevities sake I shortened it.)

But still can't put t to strSQL. Can't change it to String, and it doesn't have .Text or .Value as members to access... so Maybe I'm on stupid pills today, but I don't know what to do.
(Everybody coming in and asking me to do stupid things isn't helping my thought process either.)
 
Your sure it doesn't have those values? Something is completely funky then. During design time it will always have those members they are part of the textbox object. If something should fail it would be during the cast it the control wasn't a textbox.

A nice trick I picked up from Paul is to call the findcontrol method of a cell rather than using the 0 based index.

Dim t As TextBox = CType((_item.Cells(0).FindControl("Pack1"), TextBox)

It's more precise, less likely to fail and all.

Do you use VS? If so does the Intellisense bring up the memebers for t? Try stepping through with the debugger and find out what Pack1 is coming back as. You can use a Watch window and type this code into it to check if the cast is succeeding.

CType(_item.Cells(0).findControl("Pack1"), TextBox)


Is Pack1 a textbox or something else. If it is something else then cast it to that object instead of a textbox.

Also are you sure that you want to access cell(0)? You can check all this using the debugger.

Hopefully that does it for you anyway. That'l do donkey, that'l do
[bravo] Mark
If you are unsure of forum etiquette check here faq796-2540
 
K, I see now... like I said, many interuptions. Since I have so many elements in this one, I'm doing this:
Code:
strSQL += "A=" & CType(_item.Cells(0).FindControl("Pack1"), TextBox).Text

Thanks for the patience and help. BTW, any downfalls to doing it this way?
 
Yep, one.

The string concatenation. See faq855-1882

Other than that none that I know of. That'l do donkey, that'l do
[bravo] Mark
If you are unsure of forum etiquette check here faq796-2540
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top