Urgent
-
hi everyone, i have a datagrid that displayed data from a database. i have 2 template columns, the first one with a check box. the second one with a drop down list.When a user change the value in the drop down list the check box should be checked automatically. my code is: Dim item As DataGridItem For Each item In Me.DataGrid1.Items Dim cbRules As CheckBox = item.Cells(0).Controls(1) Dim ddEvent As dropdownlist = item.Cells(14).Controls(1) Me.ddEvent.Attributes.Add("OnChange", "checkcbEvent();") Next the function checkcbEvent() is a javascript function: function checkcbEvent() { document.Form1.cbRules.checked = true; } but it gives me an error: document.Form1.cbRules is null or not an object Can anyone help?????
-
hi everyone, i have a datagrid that displayed data from a database. i have 2 template columns, the first one with a check box. the second one with a drop down list.When a user change the value in the drop down list the check box should be checked automatically. my code is: Dim item As DataGridItem For Each item In Me.DataGrid1.Items Dim cbRules As CheckBox = item.Cells(0).Controls(1) Dim ddEvent As dropdownlist = item.Cells(14).Controls(1) Me.ddEvent.Attributes.Add("OnChange", "checkcbEvent();") Next the function checkcbEvent() is a javascript function: function checkcbEvent() { document.Form1.cbRules.checked = true; } but it gives me an error: document.Form1.cbRules is null or not an object Can anyone help?????
Hi there, This is because cbRules is a server-side variable. You need to add the id to the cbRules control such that the client-side script can find it, e.g. Server-side:
Dim cbRules as CheckBox = item.Cells(0).Controls(1)
cbRules.ID = "idCbRules"
...
...Client-side:
function checkcbEvent()
{
var elCb = document.getElementById("idCbRules");
if (elCb) elCb.checked = true;
}Hope this helps, Andy