Link to home
Start Free TrialLog in
Avatar of dpd3891
dpd3891Flag for United States of America

asked on

Access "dynamically created controls on page load" in page postback

hi experts,

I want to create table with name and checkbox for the values from database (I am trying to create it as dynamically...)
and then on submit button, the items for which checkbox is checked, want to calculate few fields from database.... and update database related to that checkbox.

I tried to do it as two ways
1. with client side controls in code behind, on page load. I am not able to retrieve the checkbox checked values on page postback.......
 'strDisplay.Text = strDisplay.Text & "<tr><td>" & reader2("name").ToString & " : </td><td><input type='checkbox' id='item" & reader("item").ToString & " ' name='' onclicked=saveItems(); style='font-family:Verdana; font-size:11px; width:50px;' /></td></tr>"

where strDisplay is label..........


2. created server side controls on page load, but it gets disappeared on page postback
                    Dim tc As New TableCell()
                    Dim tc2 As New TableCell()
                    Dim tr As New TableRow()
                    tc.Style.Add("font-size", "11px")
                    tc.Style.Add("font-family", "Verdana")
                    tc2.Style.Add("font-size", "11px")
                    tc2.Style.Add("font-family", "Verdana")

                    Dim _lbl As Label = New Label()
                    _lbl.ID = "lbl" & reader("item").ToString
                    _lbl.Text = reader2("name").ToString
                    tc.Controls.Add(_lbl)
                    Dim _checkbox As CheckBox = New CheckBox()
                    _checkbox.ID = "chk" & reader("item").ToString
                    tc2.Controls.Add(_checkbox)
                    tr.Cells.Add(tc)
                    tr.Cells.Add(tc2)
                    tbl.Rows.Add(tr)
                    Panel1.Controls.Add(tbl)


Can you please help me to get dynamically created checkbox values on page postback.......

I am using VS 2010 and SQL Server 2008 and implementing all this using vb.net.

Thanks.
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Avatar of dpd3891

ASKER

nothing seems work..........all are talking about how to create dynamic controls that I have already created......

I want to get values of those controls after page postback...

Thanks......
ASKER CERTIFIED SOLUTION
Avatar of HainKurt
HainKurt
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial