This is a migrated thread and some comments may be shown as answers.

item.GetDataKeyValue returns Null

1 Answer 279 Views
Grid
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 30 Jun 2010, 05:05 PM
Here's where I am at,

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");

 

}

}

}

1 Answer, 1 is accepted

Sort by
0
Accepted
Daniel
Telerik team
answered on 30 Jun 2010, 10:20 PM
Hello David,

Please make sure that you added these datakey names to the DataKeyNames collection:
<MasterTableView DataKeyNames="widgetStatus,widgetPostion" ...>

Regards,
Daniel
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
David
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Share this question
or