How to set navigation url for link buttonfield in datagrid

Last post 08-28-2008 10:57 AM by Puneri. 8 replies.

Sort Posts:

  • How to set navigation url for link buttonfield in datagrid

    07-07-2008, 9:19 AM
    • Member
      11 point Member
    • Puneri
    • Member since 07-06-2008, 10:15 AM
    • Posts 18

     Hello

    I've to display case id in column 0. I have made this field as buuttonfield link type. So when bind data text in each row should be case id. Since it is link button, onclick it should open new window and selected case id should be request parameter. I'm using onclient click method of linkbutton control. but When I click case id url, same page reloads. How to set navigation url for link button?

    1    gvEmTickets.DataSource = lEmTicket
    2 gvEmTickets.DataBind()
    3 4 Dim iCountTicket As Int16 = lEmTicket.Count
    5 Dim iRow As Int16 = gvEmTickets.Rows.Count()
    6 7 8 Dim i As Int16 = 0
    9 10 While i < iRow
    11 12 If i < 10 And i < iRow Then
    13 Dim
    row As GridViewRow = gvEmTickets.Rows(i)
    14 Dim hl As LinkButton = row.Cells(0).Controls(0)
    15 hl.OnClientClick = ("<a href='javascript:void(0);'" & _
    16 "
    onclick='window.open(""frmEmDetail.aspx?ticketId=" & Server.HtmlDecode(row.Cells(0).Text).ToString & _
    17 "&option=All"", ""null"", ""height=1000,width=1100,status=yes,toolbar=no,menubar=no,location=no,fullscreen =no,scrollbars=1"")'></a>") 18 i = i + 1
    19 End If
    20 End While
     
  • Re: How to set navigation url for link buttonfield in datagrid

    07-07-2008, 9:36 AM
    Answer
    • Contributor
      5,699 point Contributor
    • Pushkar
    • Member since 02-17-2006, 7:27 AM
    • Vibrant Gujarat
    • Posts 1,085

    Take HyperLink instead link button...it will work fine
     

    “ There is no great genius without some touch of madness. ”


    Remember to click “Mark as Answer” on the post If you get answer from my post(s) !

    Thanks Guys
    ------------
    Pushkar M Rathod
  • Re: How to set navigation url for link buttonfield in datagrid

    07-08-2008, 3:46 AM
    • Member
      11 point Member
    • Puneri
    • Member since 07-06-2008, 10:15 AM
    • Posts 18

     Thanks buddy..

  • Re: How to set navigation url for link buttonfield in datagrid

    07-09-2008, 3:12 AM
    • Member
      11 point Member
    • Puneri
    • Member since 07-06-2008, 10:15 AM
    • Posts 18

    I have some doubt in setting navigation url. How to write navigation url so that it opens in new window?

    I tried to use window.open and then navigation url. But that gives error.
     

  • Re: How to set navigation url for link buttonfield in datagrid

    07-09-2008, 3:23 AM
    • Contributor
      5,699 point Contributor
    • Pushkar
    • Member since 02-17-2006, 7:27 AM
    • Vibrant Gujarat
    • Posts 1,085

    Try this.. 

    <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="#" >HyperLink</asp:HyperLink>

    in the code part

    HyperLink1.Attributes.Add("onClick", "window.open('SiteURL','windownname','location=1,status=1,scrollbars=1,width=100px,height=100px, top=100px, left=100px')");

    “ There is no great genius without some touch of madness. ”


    Remember to click “Mark as Answer” on the post If you get answer from my post(s) !

    Thanks Guys
    ------------
    Pushkar M Rathod
  • Re: How to set navigation url for link buttonfield in datagrid

    07-09-2008, 9:43 AM
    • Member
      11 point Member
    • Puneri
    • Member since 07-06-2008, 10:15 AM
    • Posts 18

    Hi

    I tried this method but getting error as invalid character in url.

     

    1    <asp:HyperLinkField DataTextField="ticketId" HeaderText="Ticket Id" NavigateUrl="#">
    2      <ItemStyle CssClass="gridItemStyle" Width="70px" />
    3      <HeaderStyle CssClass="gridHeaderStyle" Width="70px" />
    4    </asp:HyperLinkField>
    5                        
    

      and vb code file

     

    1    Dim row As GridViewRow = gvEmTickets.Rows(i)
    2    Dim hl As HyperLink = row.Cells(0).Controls(0)
    3    hl.Attributes.Add("onClick", "window.open('frmEmReport.aspx?ticketId=" & hl.Text & "','Emergency Ticket Details','location=1,status=1,scrollbars=1,width=100px')")
    4    
    5    'hl.NavigateUrl = "frmEmReport.aspx?ticketId=" & hl.Text
    

      line 5 is opening page correctly. Please let me know if this syntax is correct.

    TIA,

    Puneri 

  • Re: How to set navigation url for link buttonfield in datagrid

    07-09-2008, 9:46 AM
    • Contributor
      5,699 point Contributor
    • Pushkar
    • Member since 02-17-2006, 7:27 AM
    • Vibrant Gujarat
    • Posts 1,085
    hl.Attributes.Add("onClick", "javascript:window.open('frmEmReport.aspx?ticketId=" & hl.Text & "','Emergency Ticket Details','location=1,status=1,scrollbars=1,width=100px')");

     

    “ There is no great genius without some touch of madness. ”


    Remember to click “Mark as Answer” on the post If you get answer from my post(s) !

    Thanks Guys
    ------------
    Pushkar M Rathod
  • Re: How to set navigation url for link buttonfield in datagrid

    07-09-2008, 11:04 AM
    • Member
      11 point Member
    • Puneri
    • Member since 07-06-2008, 10:15 AM
    • Posts 18

    I'm still getting error on page. In error details I get 'Invalid argument'

    In error details, line no 286 and char 1 is written.

    But my aspx page has hardly 100 lines. How do I find which statement is actually causing error?

  • Re: How to set navigation url for link buttonfield in datagrid

    08-28-2008, 10:57 AM
    • Member
      11 point Member
    • Puneri
    • Member since 07-06-2008, 10:15 AM
    • Posts 18

     added  target = "_blank" and everything worked fine as expected

     thx ppl

Page 1 of 1 (9 items)