AndyGB4
Posts: 122
|
Posted: 05/15/2013, 1:16 PM |
|
Hi everyone,
I'm trying to access a field that is in a grid (with 4 to 5 records).
Name: itemQty
Grid Name: itemsForm
In a "Before Show" action of a different label in the grid, I need to access the "itemQty" value to calculate something, but because there are more than 1 "itemQty" textBoxes (1 on each record), how do I get the one from the same record as the label that's doing the event?
If I just go get it with:
itemsForm.GetControl<MTTextBox>("itemQty").Text
Then it only gives me the 1st occurence of the textbox in the whole grid. So it works for label on the first row, but it doesn't work for any other rows.
I've also tried putting in the ID of the TextBox from the HTML that had the GridName, TextBox Name and the {RowComponents:rowNumber} thing at the end which gives each control a number based on its row.
Can anybody help me out?
|
|
|
cvboucher
Posts: 191
|
Posted: 05/17/2013, 2:44 AM |
|
I once had to do something similar. When a user clicked on an Image Button in a row I needed to access a value in a textbox in that same row. I used the following (VB.Net) code.
Dim tb As MTTextBox = CType(sender, MTImageButton).Parent.FindControl("NameOfControl")
HTH,
Craig
|
|
|
AndyGB4
Posts: 122
|
Posted: 05/17/2013, 11:54 AM |
|
Yup! that was exactly it!
I ended up using this on the Button's On Click event:
MTTextBox itemQty = ((MTButton)sender).Parent.FindControl("itemQty") as MTTextBox; string quantity = itemQty.Text;
Thanks a lot Craig!
|
|
|
|