the following is for a GridTemplateColumn:
statusCheckBox = item["checkBoxColumn"].FindControl("cbWidgetStatus") as CheckBox
This returns the control, |
all cool, when we get here: |
item.GetDataKeyValue
It returns Null. Has anyone seen this?
Thanks!
Dave Gilden
protected void rgSetUp_ItemDataBound(object sender, GridItemEventArgs e)
{
if (e.Item is GridDataItem)
{
GridDataItem item = e.Item as GridDataItem;
// Set CheckBoxes
CheckBox statusCheckBox = item["checkBoxColumn"].FindControl("cbWidgetStatus") as CheckBox;
if (statusCheckBox != null)
{
System.Diagnostics.
Debug.WriteLine( "statusCheckBox: " + item.GetDataKeyValue("widgetStatus"));
statusCheckBox.Checked = (
Boolean)item.GetDataKeyValue("widgetStatus");
}
// Set Dropdown Menus
DropDownList ddl = item["widgetPostionColumn"].FindControl("ddlWidgetPostion") as DropDownList;
if ( ddl != null )
{
System.Diagnostics.
Debug.WriteLine("widgetPostion:" + item.GetDataKeyValue("widgetPostion"));
ddl.SelectedIndex = (
int)item.GetDataKeyValue("widgetPostion");
}
}
}