Click to See Complete Forum and Search --> : dynamic control
kunal.kb
September 8th, 2005, 09:15 AM
i have created dynamic text boxes in a web form and now i want to input the data in to database using those text boxes but i am not able to catch the ID of that text boxes......any one please help me how to find the ID and use those ID into update statement of SQL
ambreesh
September 8th, 2005, 02:16 PM
please note that dynamic controls have to be created again on page load.
if you just create a dynamic controls in a function and just call that function once u will not be able to access them.
attach ur existing code here and i should be able to help.
kunal.kb
September 9th, 2005, 03:47 AM
i have created object for the text boxes.......on page load
and on button click i am transfering data to SQL database but i don't know how to get the ids of the text boxes........
this is my SQL statement----->
insert into I_Risk_Profile(Acc_Attr,Valid_Value,Invalid_Value) values(" & lookup.SelectedValue.ToString() & ",'"&&"','"&&"')"
now in the && i am giving the ID of the text boxesbut still its not working....
can u help me.....
kohlimannu
September 9th, 2005, 05:58 AM
http://www.codeguru.com/forums/showthread.php?t=353847 i have created object for the text boxes.......on page load
and on button click i am transfering data to SQL database but i don't know how to get the ids of the text boxes........
this is my SQL statement----->
insert into I_Risk_Profile(Acc_Attr,Valid_Value,Invalid_Value) values(" & lookup.SelectedValue.ToString() & ",'"&&"','"&&"')"
now in the && i am giving the ID of the text boxesbut still its not working....
can u help me.....
Hi kunal
check out this link (http://www.codeguru.com/forums/showthread.php?t=353847)
kunal.kb
September 9th, 2005, 06:56 AM
i am sorry.......
i didn't get your code......i checked the postings.....but i guess i am even more confused.....
here i am giving my code....
sorry its somewhat lengthy
c if u can give me some fix.........
-------------------------------------------------------------------
While dr.Read()
Dim i As Int32
Dim lbl As New Label
Dim txt As New TextBox
Dim txt1 As New TextBox
Dim table As New Table
Dim img1 As New ImageButton
Dim img2 As New ImageButton
txt.ID = "txt" & i
txt.Style("width") = 70
txt.Style("Height") = 20
txt.Style("Font-Size") = 11
txt.Style("Font-Names") = "Verdana"
txt.Style("MaxLength") = 9
txt.Text = dr(0)
img1.Height.Point(3)
img1.ImageUrl = "file:///C:\Inetpub\wwwroot\ISIS\images\kk.bmp"
txt1.ID = "txt1" & i
txt1.Style("width") = 70
txt1.Style("Height") = 20
txt1.Style("Font-Size") = 11
txt1.Style("Font-Names") = "Verdana"
txt1.Style("MaxLength") = 9
txt1.Text = dr(1)
img2.Height.Point(3)
img2.ImageUrl = "file:///C:\Inetpub\wwwroot\ISIS\images\kk.bmp"
Dim tdb As New TableCell
Dim tdb1 As New TableCell
Dim tdb2 As New TableCell
Dim tdb3 As New TableCell
tdb.Controls.Add(txt)
tdb1.Controls.Add(img1)
tdb2.Controls.Add(txt1)
tdb3.Controls.Add(img2)
Dim trb1 As New TableRow
Dim trb2 As New TableRow
Dim trb3 As New TableRow
Dim trb4 As New TableRow
trb1.Cells.Add(tdb)
trb1.Cells.Add(tdb1)
trb2.Cells.Add(tdb2)
trb2.Cells.Add(tdb3)
Table1.Rows.Add(trb1)
'Table1.Rows.Add(trb1)
Table2.Rows.Add(trb2)
'Table2.Rows.Add(trb2)
Place.Controls.Add(Table1)
Place2.Controls.Add(Table2)
i += 1
End While
---------------------------------------------------------
kunal.kb
September 9th, 2005, 07:52 AM
any one please tell me
is this query corret or not
if not please suggest me the correct one
"insert into I_Risk_Profile(Acc_Attr,Valid_Value,Invalid_Value) values('" & lookup.SelectedValue.ToString() & "','"&txti.text"','"&txt1i.text"')"
ambreesh
September 10th, 2005, 02:35 PM
did u put breakpoints and see what the id gives u. first of all when u do a textbox.text as u've done in ur code u will get the TextBox value and not id, u might want to do a textbox.id to get the id of the text box.
whats the error message that it gives u?
kunal.kb
September 12th, 2005, 01:44 AM
i am getting IDs as txt0,txt10,txt1,txt11......and so on.....but in that insert statement how do i use these id...... its giving syntax error...
hay! do u have any idea how to use array list....and can i store these IDsin that array list....
if yes please tell me how....
ambreesh
September 12th, 2005, 02:31 AM
it gives syntax errror....................
this is too vague of a statement, please copy and paste the error messsage. u dont need to use arraylist its just waste of memory.
send us the syntax error we will figure it out..
kunal.kb
September 12th, 2005, 05:09 AM
i tried to enter IDs but it is showing a blue line below it which indicates an error
kunal.kb
September 12th, 2005, 07:36 AM
hay
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 190: For i = 0 To n
Line 191: 'x = lookup.SelectedValue.ToString()
Line 192: y.ID = myControl1.ID.ToString()
Line 193: 'z = myControl2.ID
Line 194: Response.Write(y) ', z)
this is the error page and line number 192 has some error....
can u find a fix
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.