F
Forconi Boris via .NET 247
Hi, I'm working on a project in witch I have to list data(products that can be selected with a certain quantity) from anXML document, with key words entered by the user. A Table isdynamically created with text, and in each row, there 's atextBox (with an incremental ID number) in witch the user canenter a number of products. When the user clicks on the "Submit"button, I must know witch row he has selected, AND WITCH NUMBERHE HAS ENTERED in the The TextBox area.
The problem is that the Table is created dynamically (the userhas clicked on a "search" button to create the Table) so I can'tuse the AutoPostBack of each TextBox, or I lose the entireTable. I thought about using ViewState, but to store data I mustknow when the Text of the TextBox changed. I tried to do thiswith a AddHandler, but the TextChanged Method is never called!!
I don't know how to solve this problem. Help me !!!
Here is a part of my code (where numResult is the number of rows):
Protected TableResult As Table
Dim numResult As Integer
'(My TextChanged Function to store info)
Public Sub TB_Changed(ByVal sender As Object, ByVal e AsEventArgs)
Dim i As Integer = 0
While (i < numResult)
ViewState(Convert.ToString(i)) = sender.Text
i = i + 1
End While
End Sub
'(A part of the function that fill the Table)
Public Sub ResultsView(ByVal PRef As String, ByVal PDes AsString)
Dim compteur As Integer = 0
Dim r As New TableRow
Dim c1 As New TableCell
c1.Text = "Qt?"
r.Cells.Add(c1)
TableResult.Rows.Add(r)
While (compteur < numResult)
Dim ro As New TableRow
Dim ce1 As New TableCell
Dim txtB As New System.Web.UI.WebControls.TextBox
txtB.ID = Convert.ToString(compteur)
AddHandler txtB.TextChanged, AddressOf TB_Changed
ce1.Controls.Add(txtB)
ro.Cells.Add(ce1)
compteur = compteur + 1
End While
End Sub
Thank u for responding
(I hope u'll understand, my English is not really good...)
The problem is that the Table is created dynamically (the userhas clicked on a "search" button to create the Table) so I can'tuse the AutoPostBack of each TextBox, or I lose the entireTable. I thought about using ViewState, but to store data I mustknow when the Text of the TextBox changed. I tried to do thiswith a AddHandler, but the TextChanged Method is never called!!
I don't know how to solve this problem. Help me !!!
Here is a part of my code (where numResult is the number of rows):
Protected TableResult As Table
Dim numResult As Integer
'(My TextChanged Function to store info)
Public Sub TB_Changed(ByVal sender As Object, ByVal e AsEventArgs)
Dim i As Integer = 0
While (i < numResult)
ViewState(Convert.ToString(i)) = sender.Text
i = i + 1
End While
End Sub
'(A part of the function that fill the Table)
Public Sub ResultsView(ByVal PRef As String, ByVal PDes AsString)
Dim compteur As Integer = 0
Dim r As New TableRow
Dim c1 As New TableCell
c1.Text = "Qt?"
r.Cells.Add(c1)
TableResult.Rows.Add(r)
While (compteur < numResult)
Dim ro As New TableRow
Dim ce1 As New TableCell
Dim txtB As New System.Web.UI.WebControls.TextBox
txtB.ID = Convert.ToString(compteur)
AddHandler txtB.TextChanged, AddressOf TB_Changed
ce1.Controls.Add(txtB)
ro.Cells.Add(ce1)
compteur = compteur + 1
End While
End Sub
Thank u for responding
(I hope u'll understand, my English is not really good...)