I have a grid which has the CarrierID specified as the "DataKeyNames" which is also an invisible property in the grid.
I have a hyperlink column that when clicked should pass the value of the CarrierNetID (the keyvalue for that dataitem) into my codebehind so I can then pass it to another page to bring up a record for editng based on that key value.
I'm having trouble getting the attached error:
My markup is as follows: You can see that the lnkPLMN is the hyperlink. Everything is coming out on the grid just fine, I just can't seem to pass the value.
Here is my codebehind which gets the attached error on the following line:
Can someone please help?
Code behind:
I have a hyperlink column that when clicked should pass the value of the CarrierNetID (the keyvalue for that dataitem) into my codebehind so I can then pass it to another page to bring up a record for editng based on that key value.
I'm having trouble getting the attached error:
My markup is as follows: You can see that the lnkPLMN is the hyperlink. Everything is coming out on the grid just fine, I just can't seem to pass the value.
<
telerik:RadGrid
ID
=
"RadGrid1"
DataSourceID
=
"SqlDataSource1"
ShowStatusBar
=
"true"
runat
=
"server"
AllowPaging
=
"True"
AllowSorting
=
"True"
AllowFilteringByColumn
=
"True"
AutoGenerateColumns
=
"false"
ClientSettings-Resizing-AllowColumnResize
=
"true"
DataKeyNames
=
"CarrierNetID"
OnItemDataBound
=
"RadGrid_ItemDataBound"
>
<
MasterTableView
PageSize
=
"10"
Width
=
"100%"
>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"CarrierNetID"
Visible
=
"false"
UniqueName
=
"CarrierNetID"
ItemStyle-HorizontalAlign
=
"Left"
HeaderStyle-HorizontalAlign
=
"Left"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Name"
HeaderText
=
"Carrier Name"
UniqueName
=
"Name"
SortExpression
=
"Name"
ReadOnly
=
"true"
ItemStyle-HorizontalAlign
=
"Left"
HeaderStyle-HorizontalAlign
=
"Left"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Region"
HeaderText
=
"Region"
UniqueName
=
"Region"
AllowFiltering
=
"true"
SortExpression
=
"Region"
ReadOnly
=
"true"
ItemStyle-HorizontalAlign
=
"Left"
HeaderStyle-HorizontalAlign
=
"Left"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Country"
HeaderText
=
"Country"
UniqueName
=
"Country"
SortExpression
=
"Country"
ReadOnly
=
"true"
ItemStyle-HorizontalAlign
=
"Left"
HeaderStyle-HorizontalAlign
=
"Left"
>
</
telerik:GridBoundColumn
>
<
telerik:GridTemplateColumn
HeaderText
=
"PLMN"
UniqueName
=
"PLMN"
>
<
ItemTemplate
>
<
asp:HyperLink
ID
=
"lnkPLMN"
runat
=
"server"
Target
=
"_blank"
ForeColor
=
"Blue"
>
</
asp:HyperLink
>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridBoundColumn
DataField
=
"TechnologyTypeCode"
HeaderText
=
"Technology"
UniqueName
=
"TechnologyTypeCode"
SortExpression
=
"TechnologyTypeCode"
ReadOnly
=
"true"
ItemStyle-HorizontalAlign
=
"Left"
HeaderStyle-HorizontalAlign
=
"Left"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"SMSMORate"
HeaderText
=
"SSMSO Rate"
UniqueName
=
"SMSMORate"
AllowFiltering
=
"false"
SortExpression
=
"SMSMORate"
ReadOnly
=
"true"
ItemStyle-HorizontalAlign
=
"Right"
HeaderStyle-HorizontalAlign
=
"Right"
DataFormatString
=
"{0:G}"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"SMSMTRate"
HeaderText
=
"SMSMT Rate"
UniqueName
=
"SMSMTRate"
AllowFiltering
=
"false"
SortExpression
=
"SMSMTRate"
ReadOnly
=
"true"
ItemStyle-HorizontalAlign
=
"Right"
HeaderStyle-HorizontalAlign
=
"Right"
DataFormatString
=
"{0:G}"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"DataRate"
HeaderText
=
"Data Rate"
UniqueName
=
"DataRate"
AllowFiltering
=
"false"
SortExpression
=
"DataRate"
ReadOnly
=
"true"
ItemStyle-HorizontalAlign
=
"Right"
HeaderStyle-HorizontalAlign
=
"Right"
DataFormatString
=
"{0:G}"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"MOCRate"
HeaderText
=
"MOC Rate"
UniqueName
=
"MOCRate"
AllowFiltering
=
"false"
SortExpression
=
"MOCRate"
ReadOnly
=
"true"
ItemStyle-HorizontalAlign
=
"Right"
HeaderStyle-HorizontalAlign
=
"Right"
DataFormatString
=
"{0:G}"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"MTCRate"
HeaderText
=
"MTC Rate"
UniqueName
=
"MTCRate"
AllowFiltering
=
"false"
SortExpression
=
"MTCRate"
ReadOnly
=
"true"
ItemStyle-HorizontalAlign
=
"Right"
HeaderStyle-HorizontalAlign
=
"Right"
DataFormatString
=
"{0:G}"
>
</
telerik:GridBoundColumn
>
<
telerik:GridCheckBoxColumn
DataField
=
"FlatRate"
HeaderText
=
"Flat Rate"
UniqueName
=
"FlatRate"
SortExpression
=
"FlatRate"
ReadOnly
=
"true"
ItemStyle-HorizontalAlign
=
"Center"
HeaderStyle-HorizontalAlign
=
"Center"
>
</
telerik:GridCheckBoxColumn
>
<
telerik:GridCheckBoxColumn
DataField
=
"Discount"
HeaderText
=
"Discount"
UniqueName
=
"Discount"
SortExpression
=
"Discount"
ReadOnly
=
"true"
ItemStyle-HorizontalAlign
=
"Center"
HeaderStyle-HorizontalAlign
=
"Center"
>
</
telerik:GridCheckBoxColumn
>
<
telerik:GridCheckBoxColumn
DataField
=
"ActiveFlag"
HeaderText
=
"Active"
UniqueName
=
"ActiveFlag"
SortExpression
=
"ActiveFlag"
ReadOnly
=
"true"
ItemStyle-HorizontalAlign
=
"Center"
HeaderStyle-HorizontalAlign
=
"Center"
>
</
telerik:GridCheckBoxColumn
>
</
Columns
>
</
MasterTableView
>
<
ClientSettings
EnableRowHoverStyle
=
"true"
>
</
ClientSettings
>
<
PagerStyle
Mode
=
"NumericPages"
></
PagerStyle
>
</
telerik:RadGrid
>
Here is my codebehind which gets the attached error on the following line:
HyperLink link = (HyperLink)item["PLMN"].Controls[0];
protected void RadGrid_ItemDataBound(object sender, GridItemEventArgs e)
{
if (e.Item is GridDataItem)
{
GridDataItem item = (GridDataItem)e.Item;
HyperLink link = (HyperLink)item["PLMN"].Controls[0];
string value = item.GetDataKeyValue("CarrierNetID").ToString();
link.NavigateUrl = "~/CarrierLaunchStatusForm.aspx?addRecord=0&ID=" + value;
}
}
Can someone please help?
Code behind: