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

RadGrid Hyperlink Column

12 Answers 1055 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Sarath
Top achievements
Rank 1
Sarath asked on 05 Jul 2010, 02:13 PM
Hi,
I am using a radgrid in my application as given below.

 

<telerik:RadGrid ID="RadGridMeasuresList" runat="server" AllowPaging="True" AutoGenerateColumns="False" Width="700px" ShowFooter="false" Skin="WebBlue" BorderColor="White" BackColor="White" ItemStyle-BorderColor="Black" Height="300px" HeaderStyle-ForeColor="Black" onitemdatabound="RadGridMeasuresList_ItemDataBound" onitemcreated="RadGridMeasuresList_ItemCreated">

 

 

<ItemStyle BorderColor="Black" />
<MasterTableView>

 

 

<Columns>

 

 

<telerik:GridBoundColumn HeaderText="Measure" DataField="MeasureName" HeaderStyle-Wrap="false" ItemStyle-Wrap="true" HeaderStyle-Width="250px" ItemStyle-HorizontalAlign="Left" HeaderStyle-Font-Bold="false">

 

 

</telerik:GridBoundColumn>

 

 

<telerik:GridBoundColumn HeaderText = "Total Opportunities" DataField="Opportunities" HeaderStyle-Wrap="false" UniqueName="Opportunities" ItemStyle-HorizontalAlign="Left" HeaderStyle-Font-Bold="false">

 

 

<ItemStyle Wrap="True"/>

 

 

</telerik:GridBoundColumn >

 

 

<telerik:GridHyperLinkColumn HeaderText = "Patients with Clinical Alerts" DataTextField="NonComplianceCount" ItemStyle-HorizontalAlign="Left" UniqueName="NonComplianceCount" HeaderStyle-Font-Bold="false" HeaderStyle-Wrap="false" DataNavigateUrlFields="Condition,Measure" DataNavigateUrlFormatString="IPClinicalAlerts.aspx?Condition={0}&Measure={1}&IsCompliant=False&PatientSearch=0" HeaderStyle-Width="150px">

 

 

<ItemStyle Wrap="True" Font-Underline="true"/>

 

 

</telerik:GridHyperLinkColumn>

 

 

<telerik:GridBoundColumn HeaderText = "Compliance Rate" DataField="Rate" HeaderStyle-Wrap="false" UniqueName="Rate" ItemStyle-HorizontalAlign="Left" HeaderStyle-Font-Bold="false">

 

 

<ItemStyle Wrap="True" />

 

 

</telerik:GridBoundColumn>

 

 

</Columns>

 

 

</MasterTableView>

 

 

<HeaderStyle BackColor="#E1E1E1" Font-Bold="True"/>

 

 

<clientsettings enablerowhoverstyle="True" >

 

 

<selecting allowrowselect="True" />

 

 

<scrolling AllowScroll="true" usestaticheaders="True" />

 

 

</clientsettings>

 

 

</telerik:RadGrid>

Here are the 2 problems i am facing
1.When i view this grid in browser i am not getting a Underline for the values in the Hyperlink column even after setting Underline property as true for the Items. Even i tried setting using CssClass but i am not able to acheive it.
2.On mouse over the values in the HyperLink columns i am getting a tooltip displaying the same values. How to hide the tooltip.

Thanks in advance,
Sharath

 

12 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 06 Jul 2010, 06:45 AM
Hello Sarath,

I did not experience this issue on my end, even I tried in IE, firefox and Opeara browsers. Make sure that you have not applied any style which overrides the default properties of HyperLink.

Now for hiding the ToolTip of HyperLinkColumn, access the HyperLink from code behind and set ToolTip as empty like below.

C#:
  
 protected void RadGridMeasuresList_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridDataItem) 
        { 
            GridDataItem item = (GridDataItem)e.Item; 
            HyperLink link = (HyperLink)item["NonComplianceCount"].Controls[0]; 
            link.ToolTip = ""
        } 
    } 

Thanks,
Princy.


0
prat
Top achievements
Rank 1
answered on 13 Sep 2011, 02:31 AM
I have a hyper link column in my radgrid.
Before it navigates to the given page, I want few values to be stored in a session var.
Which event will be triggered when the user clicks on the hyperlink? can it be modified to trigger the itemcommand event?
0
Princy
Top achievements
Rank 2
answered on 13 Sep 2011, 06:19 AM
Hello Prat,

1st method:
Try catching the hyperlink using the Item Created and using the onclick event you can attach your javascript.
C#:
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
   {
       if (e.Item is GridDataItem)
       {
           GridDataItem item = (GridDataItem)e.Item;
           HyperLink link = (HyperLink)item["ColUniqueName"].Controls[0];
           link.Attributes.Add("onclick", "Validate(); return false;");
       }
   }
JS:
<script type="text/javascript">
function Validate()
 {   
  alert("Not an authorized user");
 }
</script>
2nd method:
aspx:
<telerik:GridTemplateColumn>
  <ItemTemplate>
    <asp:LinkButton ID="btnlnk" runat="server" Text='<%# Eval("ColUniqueName") %>' OnClick="btnlnk_Click">
    </asp:LinkButton>
  </ItemTemplate>
</telerik:GridTemplateColumn>
C#:
protected void btnlnk_Click(object sender, EventArgs e)
 {
   LinkButton btnlnk = sender as LinkButton;
  GridDataItem item = btnlnk.NamingContainer as GridDataItem;
  //your functionality
 }

Thanks,
Princy.
0
prat
Top achievements
Rank 1
answered on 13 Sep 2011, 08:00 AM
Hello Princy,

Got it working.
Not sure how but ,Since i already had a gridbuttoncloumn, clicking the hyperlink triggers the item command event as well.
Hence smoothly working.
Is it a risky process??
0
Rachana
Top achievements
Rank 1
answered on 28 Mar 2012, 11:46 AM

 Explain about radgrid index..bcoz am displaying s.no and somemsg in two coloumns if am chking indexes
it is showing s.no is cells[2] and somemsg is cells[3] and wat abt [0],[1]


0
Shinu
Top achievements
Rank 2
answered on 28 Mar 2012, 01:00 PM
Hi Swetha,

The column index starts at index 2 beacuse GridExpandColumn and GridRowindicatorColumn are always in front of data columns.

Because of features such as column reordering and grouping, the index of individual columns can change on the client. This means that using indexes to access individual cells in the Cells collection of a row is not a reliable method of obtaining a cell in a particular column.
You can also access the cell using its Column's UniqueName.

Thanks,
-Shinu.
0
Margret
Top achievements
Rank 1
answered on 12 Apr 2013, 01:02 PM
Hi all,
I have a hyperlink column in my radgrid.How can i get the value of hyperlink column value in item data bound event?
0
Princy
Top achievements
Rank 2
answered on 12 Apr 2013, 01:06 PM
Hi,

Please try the following code snippet to access the GridHyperlinkColumn in ItemDataBound event.

C#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
    if (e.Item is GridDataItem)
    {
        GridDataItem ditem = (GridDataItem)e.Item;
        HyperLink hyper = (HyperLink)ditem["UniqueName"].Controls[0];
        string value = hyper.Text;
    }
}

Thanks,
Princy.
0
Margret
Top achievements
Rank 1
answered on 12 Apr 2013, 01:15 PM
Thanks for your quick reply.
If a have a button in the same row of the chyperlink column.How can i get the hyperlink column value in the button click event.(Not in the onclick event)?   like the below function:

 

protected void btnChange_Click(object sender, EventArgs e)
{

Button btn = (Button)sender;

GridDataItem item = (GridDataItem)btn.NamingContainer;

TableCell cell1 = (TableCell)item["Name"];

string clvalue = cell.Text;

}

 

 

 

 

0
Margret
Top achievements
Rank 1
answered on 12 Apr 2013, 01:56 PM
hi.any update on this?
0
Princy
Top achievements
Rank 2
answered on 15 Apr 2013, 06:30 AM
Hi,

Please take a look into the following code snippet.

C#:
protected void Button1_Click(object sender, EventArgs e)
{
    Button btn = (Button)sender;
    GridDataItem ditem = (GridDataItem)btn.NamingContainer;
    HyperLink hyper = (HyperLink)ditem["UniqueName"].Controls[0]; // access the hyperlink here
}

Thanks,
Princy.
0
Margret
Top achievements
Rank 1
answered on 15 Apr 2013, 11:48 AM
Thanks.It is working fine
Tags
Grid
Asked by
Sarath
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
prat
Top achievements
Rank 1
Rachana
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Margret
Top achievements
Rank 1
Share this question
or