RadGrid Hyperlink Column

13 posts, 0 answers
  1. Sarath
    Sarath avatar
    1 posts
    Member since:
    Jul 2010

    Posted 05 Jul 2010 Link to this post

    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

     

  2. Princy
    Princy avatar
    17414 posts
    Member since:
    Mar 2007

    Posted 06 Jul 2010 Link to this post

    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.


  3. prat
    prat avatar
    10 posts
    Member since:
    Jul 2011

    Posted 12 Sep 2011 Link to this post

    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?

  4. Princy
    Princy avatar
    17414 posts
    Member since:
    Mar 2007

    Posted 13 Sep 2011 Link to this post

    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.

  5. prat
    prat avatar
    10 posts
    Member since:
    Jul 2011

    Posted 13 Sep 2011 Link to this post

    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??

  6. Rachana
    Rachana avatar
    18 posts
    Member since:
    Jul 2011

    Posted 28 Mar 2012 Link to this post

     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]


  7. Shinu
    Shinu avatar
    17757 posts
    Member since:
    Mar 2007

    Posted 28 Mar 2012 Link to this post

    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.

  8. Margret
    Margret  avatar
    47 posts
    Member since:
    Mar 2013

    Posted 12 Apr 2013 Link to this post

    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?

  9. Princy
    Princy avatar
    17414 posts
    Member since:
    Mar 2007

    Posted 12 Apr 2013 Link to this post

    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.

  10. Margret
    Margret  avatar
    47 posts
    Member since:
    Mar 2013

    Posted 12 Apr 2013 Link to this post

    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;

    }

     

     

     

     

  11. Margret
    Margret  avatar
    47 posts
    Member since:
    Mar 2013

    Posted 12 Apr 2013 Link to this post

    hi.any update on this?

  12. Princy
    Princy avatar
    17414 posts
    Member since:
    Mar 2007

    Posted 15 Apr 2013 Link to this post

    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.

  13. Margret
    Margret  avatar
    47 posts
    Member since:
    Mar 2013

    Posted 15 Apr 2013 Link to this post

    Thanks.It is working fine

Back to Top