
Mahesh Babu
Top achievements
Rank 1
Mahesh Babu
asked on 29 Jul 2009, 09:04 AM
Hi,
I have a radGrid to which I add GridHyperlinkColumn at runtime. I need to pass Navigation urls to these which depends on the values of the other cells.
GridHyperLinkColumn column = (GridHyperLinkColumn)gridBoundColumns[j];
column.DataTextField = gridField.DataField;
column.HeaderText = gridField.HeaderText;
column.NavigateUrl = "accountview.aspx?id=<%# Eval(\"AccountID\") %>";
If I pass the NavigateUrl value as above it is taking as a string but not replacing Eval("AccountID") to the value in that cell.
How to achieve this functionality like this???
Thanks,
Mahesh
I have a radGrid to which I add GridHyperlinkColumn at runtime. I need to pass Navigation urls to these which depends on the values of the other cells.
GridHyperLinkColumn column = (GridHyperLinkColumn)gridBoundColumns[j];
column.DataTextField = gridField.DataField;
column.HeaderText = gridField.HeaderText;
column.NavigateUrl = "accountview.aspx?id=<%# Eval(\"AccountID\") %>";
If I pass the NavigateUrl value as above it is taking as a string but not replacing Eval("AccountID") to the value in that cell.
How to achieve this functionality like this???
Thanks,
Mahesh
5 Answers, 1 is accepted
0
Hi Mahesh,
Expressions are allowed only in Controls - grid columns are abstract objects (IStateManager). You can use ItemDataBound or ItemCreated to find the Hyperlink control and assign desired property value directly. Other possible solution will be to use template column where you can use binding expression without problems.
Regards,
Vlad
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Expressions are allowed only in Controls - grid columns are abstract objects (IStateManager). You can use ItemDataBound or ItemCreated to find the Hyperlink control and assign desired property value directly. Other possible solution will be to use template column where you can use binding expression without problems.
Regards,
Vlad
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0

Guramar Sekhon
Top achievements
Rank 1
answered on 27 Aug 2009, 11:19 AM
<Columns>
<telerik:GridEditCommandColumn HeaderText="Edit" UniqueName="EditCommandColumn" ButtonType="imagebutton" />
<telerik:GridBoundColumn DataField="continent_name" HeaderText="Name Of Continent"
SortExpression="continent_name" UniqueName="continent_name">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="dt_created" DataType="System.DateTime" ReadOnly="true"
HeaderText="Date Of Creation" SortExpression="dt_created" UniqueName="dt_created" DataFormatString="{0:d}">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="dt_modified" DataType="System.DateTime" ReadOnly="true"
HeaderText="Modified Date" SortExpression="dt_modified" UniqueName="dt_modified" DataFormatString="{0:d}">
</telerik:GridBoundColumn>
<telerik:GridCheckBoxColumn DataField="status" DataType="System.Boolean"
HeaderText="Status" SortExpression="status" UniqueName="status">
</telerik:GridCheckBoxColumn>
<telerik:GridCheckBoxColumn DataField="deleted" DataType="System.Boolean"
HeaderText="Deleted" SortExpression="deleted" UniqueName="deleted">
</telerik:GridCheckBoxColumn>
<telerik:GridTemplateColumn UniqueName="TemplateColumn"
HeaderText="View of Countries" DataField="cont_id"
DataType="System.Int32" HeaderTooltip="View associated Countries">
<ItemTemplate>
<asp:HyperLink runat="server" Text="View" NavigateUrl="~/Embraled/Lcountry.aspx?cont_id=<%#Eval('cont_id')%> "></asp:HyperLink>
</ItemTemplate>
</telerik:GridTemplateColumn>
</Columns>
***************************************************************************************************************************
In the above code snippet , i am getting the error....
I do have same issue and i did as per suggestion like passing in template but althought i m getting the same string it is not being replaxed by required "cont_id".
Please suggest me how can i acheive the required target....
0
Hi Guramar,
Attached to this message, is a small application, which handles a similar task.
Take a look at the code, and let me know how it goes.
Best wishes,
Yavor
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Attached to this message, is a small application, which handles a similar task.
Take a look at the code, and let me know how it goes.
Best wishes,
Yavor
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0

william
Top achievements
Rank 1
answered on 19 Jan 2011, 12:08 AM
Hi,
it didn't work for me. the application throws the following exception:
"Databinding expressions are only supported on objects that have a DataBinding event. Telerik.Web.UI.GridHyperLinkColumn does not have a DataBinding event."
Here is the code behind:
And what about if I would have more than only one parameter? how does it work?, There is another issue, if I try to do it by means of an Itemdatabound method I'm getting the following error: HTTP Error 404 - Not Found.
Thanks in advance
William
it didn't work for me. the application throws the following exception:
"Databinding expressions are only supported on objects that have a DataBinding event. Telerik.Web.UI.GridHyperLinkColumn does not have a DataBinding event."
Here is the code behind:
<
telerik:RadGrid
ID
=
"grvStatusInvoice"
runat
=
"server"
AllowPaging
=
"True"
AllowSorting
=
"True"
GridLines
=
"None"
onneeddatasource
=
"grvStatusInvoice_NeedDataSource"
AutoGenerateEditColumn
=
"True"
DataSourceID
=
"ldsStatusInvoice"
AllowAutomaticDeletes
=
"True"
AllowAutomaticInserts
=
"True"
AllowAutomaticUpdates
=
"True"
AutoGenerateDeleteColumn
=
"True"
Skin
=
"WebBlue"
>
<
ClientSettings
>
<
Selecting
AllowRowSelect
=
"True"
/>
</
ClientSettings
>
<
MasterTableView
DataSourceID
=
"ldsStatusInvoice"
AutoGenerateColumns
=
"False"
DataKeyNames
=
"SAPCompanyId,StatusCode1"
CommandItemDisplay
=
"Top"
>
<
CommandItemSettings
ExportToPdfText
=
"Export to Pdf"
></
CommandItemSettings
>
<
RowIndicatorColumn
>
<
HeaderStyle
Width
=
"20px"
></
HeaderStyle
>
</
RowIndicatorColumn
>
<
ExpandCollapseColumn
>
<
HeaderStyle
Width
=
"20px"
></
HeaderStyle
>
</
ExpandCollapseColumn
>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"SAPCompanyId"
HeaderText
=
"Sociedad"
ReadOnly
=
"True"
SortExpression
=
"SAPCompanyId"
UniqueName
=
"SAPCompanyId"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"StatusCode"
HeaderText
=
"Estado"
ReadOnly
=
"True"
SortExpression
=
"StatusCode"
UniqueName
=
"StatusCode"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"StatusName"
HeaderText
=
"Descripción"
SortExpression
=
"StatusName"
UniqueName
=
"StatusName"
>
</
telerik:GridBoundColumn
>
<
telerik:GridCheckBoxColumn
DataField
=
"ApprovalRequired"
DataType
=
"System.Boolean"
HeaderText
=
"Requiere Aprobación"
SortExpression
=
"ApprovalRequired"
UniqueName
=
"ApprovalRequired"
ItemStyle-HorizontalAlign
=
"Center"
>
<
ItemStyle
HorizontalAlign
=
"Center"
></
ItemStyle
>
</
telerik:GridCheckBoxColumn
>
<
telerik:GridCheckBoxColumn
DataField
=
"SapTransmission"
DataType
=
"System.Boolean"
HeaderText
=
"Transmisión a SAP"
SortExpression
=
"SapTransmission"
UniqueName
=
"SapTransmission"
ItemStyle-HorizontalAlign
=
"Center"
>
<
ItemStyle
HorizontalAlign
=
"Center"
></
ItemStyle
>
</
telerik:GridCheckBoxColumn
>
<
telerik:GridBoundColumn
DataField
=
"SapResponseCode"
ItemStyle-HorizontalAlign
=
"Center"
HeaderText
=
"Equivalencia SAP"
SortExpression
=
"SapResponseCode"
UniqueName
=
"SapResponseCode"
>
<
ItemStyle
HorizontalAlign
=
"Center"
></
ItemStyle
>
</
telerik:GridBoundColumn
>
<
telerik:GridCheckBoxColumn
DataField
=
"ContabRequired"
ItemStyle-HorizontalAlign
=
"Center"
DataType
=
"System.Boolean"
HeaderText
=
"Requiere Contabilización"
SortExpression
=
"ContabRequired"
UniqueName
=
"ContabRequired"
>
<
ItemStyle
HorizontalAlign
=
"Center"
></
ItemStyle
>
</
telerik:GridCheckBoxColumn
>
<
telerik:GridHyperLinkColumn
NavigateUrl='<%#String.Format("~/Administration/FrmSupportedStatusCodes.aspx?cont_id={0}", Eval("SAPCompanyId").ToString()) %>' UniqueName="column" HeaderText="Button Column"
Text="link button"></
telerik:GridHyperLinkColumn
>
</
Columns
>
</
MasterTableView
>
</
telerik:RadGrid
>
And what about if I would have more than only one parameter? how does it work?, There is another issue, if I try to do it by means of an Itemdatabound method I'm getting the following error: HTTP Error 404 - Not Found.
Thanks in advance
William
0
Hello william,
Have you tried the alternative solution provided in the sample attached by my colleague Yavor?
Kind regards,
Iana
the Telerik team
Have you tried the alternative solution provided in the sample attached by my colleague Yavor?
Kind regards,
Iana
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.