? placeholder checkbox unique question - need help

Results 1 to 2 of 2

Thread: ? placeholder checkbox unique question - need help

  1. #1
    Join Date
    Dec 1969

    Default ? placeholder checkbox unique question - need help

    I have a placeholder that I am filling with a checkbox in vb.net code. I need to know how/where to add code to allow for the OnSelectedIndexChanged function, so I can call a subroutine in my code when a box is checked or unchecked. For example, I read a database, and depending on values, It creates multiple checkboxes. I want to capture when the user checks or unchecks a box. Some code posted below.<BR><BR>======note=======<BR>phsoftname is the placeholder on the web form<BR>====================== start code ================<BR>Dim dsSoftOnce As DataSet = hvdSoftware.GetSoftwareByTypeOnce(strType)<BR>Dim w As Integer<BR>Dim r As DataRow<BR>Dim intCount As Integer<BR><BR>For Each r In dsSoftOnce.Tables(0).Rows<BR>intCount = intCount + 1<BR>w = w + 1<BR>Dim cbxVersion As New CheckBoxList<BR>cbxVersion.ID = "cbxVersion" & Convert.ToString(w)<BR>cbxVersion.RepeatDirection = RepeatDirection.Horizontal<BR>cbxVersion.CellPaddi ng = 5<BR><BR><BR>Dim dsSoftByName As DataSet = hvdSoftware.GetSoftwareVersionByName(lblsoftname.T ext)<BR>Dim vv As DataRow<BR>Dim ii As Integer = 0<BR>System.Web.UI.LiteralControl("&#060;/td&#062;&#060;td&#062;"))<BR>&#039;add to placeholder and end cell, end row, start cell, start row<BR>phsoftname.Controls.Add(cbxVersion)<BR>phso ftname.Controls.Add(New System.Web.UI.LiteralControl("&#060;/td&#062;&#060;/tr&#062;&#060;tr&#062;&#060;td&#062;"))<BR>Next<BR >=======================end code ==================

  2. #2
    Join Date
    Dec 1969

    Default RE: ? placeholder checkbox unique question - need

    You need to add code for a SelectedIndexChanged EventHandler. I don&#039;t do VB, but here is some C# code:<BR><BR>cbxVersion.SelectedIndexChanged += new EventHandler(IndexChanged_Click);<BR><BR>And you need to create a function, IndexChanged_Click:<BR><BR>void IndexChanged_Click(object sender, EventArgs e)<BR>{<BR> // do something when one of the CheckBoxList&#039;s checkboxes is clicked<BR>}<BR><BR>I haven&#039;t actually tested this, but I&#039;d imagine you can cast sender to an object of type CheckBoxList and then determine which checkbox&#039;s state has changed.<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts