Thursday, March 20, 2008

DataGrid + On Click of Check box, Enable or Disable a Drop Down

This is how it goes..



Add Attributes to the checkbox in item data bound

For Each dgi In dgCol.Items
Dim chk As CheckBox = CType(dgi.FindControl("chkSelect"), CheckBox)
chk.Attributes.Add("onclick", "javascript:Temp('" & CType(dgi.FindControl("ddMapToColumn"), DropDownList).ClientID & "');")
Next


The Java script that does the Enabling / Disabling is as follows..

function Temp(drpdown)
{
document.getElementById(drpdown).disabled = !document.getElementById(drpdown).disabled;
}




Nothing much is required apart from this and the job is done !!

0 comments: