Click here to Skip to main content
15,949,741 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi,
i am using asp.net with code as vb.net. in one of the page i have grid to display some values. in a particular row in one column i have multiple textboxes assigned at runtime so that the end user can update the value. now i want to get the updated value of a particular text box. can any one please guide me how can i get it.

the code that i have done is as follows.
in grid_rowdatabound event i have

'odr is a reader which reads data from database. it may contain multiple rows
VB
Do While oDr.Read 

 Dim txt1 As New TextBox
                            Dim oTable1 As New Table
                            Dim oRow2 As New TableRow
                            Dim oCell2 As New TableCell

                            Dim quantity As String = oDr("Qty") & ""

                            txt1.Text = quantity
                            txt1.CssClass = "smalltextbox"
                            txt1.Width = New Unit(60, UnitType.Pixel)
                            txt1.Height = New Unit(11, UnitType.Pixel)
                            txt1.Style.Add("text-align", "right")
                            
                            oRow2.Cells.Add(oCell2)

                            oCell2.Controls.Add(txt1)
                            oCell2.HorizontalAlign = HorizontalAlign.Right
                            oTable1.Width = New Unit(100, UnitType.Percentage)
                            oTable1.Rows.Add(oRow2)
                            DirectCast(e.Row, System.Web.UI.WebControls.GridViewRow).Cells.Item(8).Controls.Add(oTable1)

Loop


what it does is it adds textboxes to a row

now for saving i have to access value of each of this textbox. how can do it? can any one please guide me.

Thanks in advance.
Posted
Updated 31-Oct-12 5:38am
v2

1 solution

If you give your Textbox controls unique IDs then you can just reference them by that ID.
VB
txt1.ID = "SomeUniqueNameBasedOnYourDataSource"
 
Share this answer
 
Comments
Jagdish.rkl 31-Oct-12 11:49am    
Thank you sir. i will check it out now
Jagdish.rkl 31-Oct-12 14:22pm    
i have done the way as told by Mr. Marcus Kramer. the problem that i am having now is at grid_rowdatabound some value is assigned to each textbox. now the end user can change the value. i need to get the updated value. but it is showing me the old value that was assigned to the textbox at rowdatabound.
suppose the id txt11.text=11
the user can updated at runtime to any value. for example say 15
when i am using
Dim txt As TextBox = DirectCast(row.Cells(8).FindControl(txt11), TextBox)
then in txt.text it is showing me 11 not 15. i want 15 to get. how can this be done.
can any one please guide me

thank you in advance

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900