.NETGURU
Pull out the check box values designed at run time.
Messages   Related Types
This message was discovered on ASPFriends.com 'aspngfreeforall' list.


Uma Ayyanathan

<script runat="server">
Public objDatabase as new Waide.DataUtility
Public ds as new System.Data.DataSet
Public count as Integer
dim strSQL as String

Sub Page_Load()
personid.Text = request("id")
DataBind()
SetData()
End Sub

Sub DataBind()
If ((personid.Text = "") or (personid.Text = "null")) then
'do nothing...
Else

objDatabase.strsql = "spGetPersonRolesNew " & Request("id")
objDatabase.Initialize()
ds = objDatabase.GetDataSet(objDatabase.strsql)
RoleDesignation.DataSource = ds
RoleDesignation.DataBind()
objDatabase = Nothing
End if
End Sub

Private Sub SetData()
Dim tbl as New Table()
Dim tblCell as New TableCell()

Dim maxcount as Integer = ds.Tables(0).DefaultView.count
For count = 0 To maxcount-1

Dim lblRolenameval as Label = New Label()
Dim lblRolecountval as Label = New Label()
Dim phRolename as PlaceHolder = New PlaceHolder
Dim phRolecount as PlaceHolder = New PlaceHolder

lblRolenameval.id = "lblRolenameval_" & count
lblRolenameval.Text =
ds.Tables(0).DefaultView.Item(count).Item("role_name").ToString
phRolename.Controls.Add(lblRolenameval)
lblRolecountval.id = "lblRolecountval_" & count
lblRolecountval.Text =
ds.Tables(0).DefaultView.Item(count).Item("role_count").ToString
phRolecount.Controls.Add(lblRolecountval)

Dim chkRoleDesigval as CheckBox = New CheckBox()
chkRoleDesigval.id = "chkRoleDesigval_" & count
If ds.Tables(0).DefaultView.Item(count).Item("role_designated").ToString
= "0" Then
chkRoleDesigval.checked = False
Else
chkRoleDesigval.checked = True
End If
Dim phCheckBox as PlaceHolder = New PlaceHolder
phCheckBox.Controls.Add(chkRoleDesigval)

Dim spacer As LiteralControl = New LiteralControl("<br>")

Panel1.Controls.Add(phRolename)
Panel1.Controls.Add(phRolecount)
Panel1.Controls.Add(phCheckBox)
Panel1.Controls.Add(spacer)
Next

End Sub

Sub btnSaveRoleDesig_onclick(obj as object, e as eventargs)
response.write(chkRoleDesigval.value)
End Sub

</script>
<body id="BodyTag" runat=server/><form runat=server>
<asp:Label id=personid runat=server visible=false />
<asp:Label id=testLabel runat=server />
<asp:DataGrid id=RoleDesignation runat=server
visible = false>
</asp:DataGrid>
<ASP:TABLE GridLines=1>
<ASP:TableRow>
<ASP:TableCell id=tblRolename>
<ASP:Label id="lblRolename"
CssClass="formBold"
text="Role Name"
runat=server/>
</ASP:TableCell>
<ASP:TableCell>
<ASP:Label id="lblRoleCount"
Size="32"
CssClass="formBold"
text="Role Count"
runat=server/>
</ASP:TableCell>
<ASP:TableCell>
<ASP:Label id="lblRoleDesignated"
Size="32"
CssClass="formBold"
text="Role Designated"
runat=server/>
</ASP:TableCell>
</ASP:TableRow>
</ASP:TABLE>
<table width=100% >
<ASP:Panel id=panel1 runat=server/>
<tr><td>
<ASP:Button id="btnSaveRoleDesig"
CssClass="form"
text="Save"
onclick="btnSaveRoleDesig_onclick"
runat=server/>
</td></tr>
</table>
</form></body>

_______________________________________________________________________

The above code adds controls programmatically with values driven from the
database. When the user hits the
save button, I am having a hard time to pull out the checkbox values
designed programmatically at runtime.
How do I pull out the checkbox values in the btnSaveRoleDesig_onclick event?
If I try to write response.write(chkRoleDesigval.checked) or
chkRoleDesigval_0.checked in the onclick event,
it gives the error message that 'chkRoleDesigval or chkRoleDesigval_0 is not
declared'.
Any ideas on how to grab the checkbox values which are designed in the Page
Load event?
Thanks,
Uma

_________________________________________________________________
Join the world’s largest e-mail service with MSN Hotmail.
http://www.hotmail.com

Reply to this message...
 
    
Srinivasa Sivakumar
Uma:

Try to look into the CheckboxList Control. This may help you bind the data
instead of generating the checkboxes at runtime.

- Srinivasa Sivakumar
Author, Developer and Reviewer
http://www3.brinkster.com/webguru/
[Visual Basic .NET Threading Handbook]
http://www.amazon.com/exec/obidos/ASIN/1861007132
[ASP.NET Security] http://www.amazon.com/exec/obidos/ASIN/1861006209
----- Original Message -----
From: "Uma Ayyanathan" <Click here to reveal e-mail address>
To: "aspngfreeforall" <Click here to reveal e-mail address>
Sent: Wednesday, August 14, 2002 2:38 PM
Subject: [aspngfreeforall] Pull out the check box values designed at run
time.

[Original message clipped]

Reply to this message...
 
 
System.Data.DataSet
System.Web.UI.LiteralControl
System.Web.UI.WebControls.CheckBox
System.Web.UI.WebControls.DataGrid
System.Web.UI.WebControls.GridLines
System.Web.UI.WebControls.PlaceHolder
System.Web.UI.WebControls.TableCell
System.Web.UI.WebControls.TableRow
System.Windows.Forms.CheckBox
System.Windows.Forms.DataGrid




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification