Click to See Complete Forum and Search --> : Not being able to select CheckBox Checked Value


TheLastBurden
04-04-2006, 03:16 AM
am trying to pass the checked values onto rqstDisplay.aspx
Does not work with the following VBScript code .

<script Language="VB" runat="server">
Sub SendToHelpDesk(sender As Object, e As EventArgs)
Dim V_DGI AS DataGridItem
Dim chkSelect As System.Web.UI.WebControls.CheckBox
For Each V_DGI in gridx.Items
chkSelect=CType(V_DGI.FindControl("CHK"),CheckBox)
If chkSelect.Checked then
h_req_id.value=CType(V_DGI.FindControl("req_id"),Label).Text
End If
Next
Server.Transfer("rqstDisplay.aspx")
End Sub
</script>
There's no error, but the value stored in h_req_id.value is blank.
Tried solving the same problem with javascript validation

<script Language=JScript >
function validate()
{
if(document.getElementById("<%=CHK.ClientID%>").checked==true)
{alert("JSCript");}
}
</script>
The above code gives the following error : BC30451: Name 'CHK' is not declared.

My HTML Form


<asp:TemplateColumn HeaderStyle-HorizontalAlign=Center HeaderText="X">
<ItemTemplate>
<asp:Checkbox ID="CHK" Runat="server" />
<asp:Label ID="req_id" Visible="False" Text='<%# DataBinder.Eval(Container.DataItem,"request_id") %>' Runat=server />
</ItemTemplate>
</asp:TemplateColumn> <input type=hidden name=h_req_id>

anyone haveany idea wh'ts wrong ?

sirpelidor
04-04-2006, 12:48 PM
1)

h_req_id.value=CType(V_DGI.FindControl("req_id"),Label).Text

<asp:Label ID="req_id" Visible="False" Text='<%# DataBinder.Eval(Container.DataItem,"request_id") %>' Runat=server />


I don't think u can read value off hidden label like this...

2)

if(document.getElementById("<%=CHK.ClientID%>").checked==true)


if you view the page source, you will see the reason javascript crash because that id doesn't exist.

3)

<input type=hidden name=h_req_id>


coming from traditional asp world? you don't need those in asp.net world