CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2003
    Posts
    417

    Linkbutton does not look like a linkbutton

    OK, I almost got my problem solved. Zen is almost there! Just that a LinkButton control inside a column in my datagrid doesn't show like a link button. It does not have an underlining. My client side JavaScript is enabled. How do I make the button underlined and appear and act like a linkbutton? Currently, it just displays the text like a normal label/table cell that has a label.

  2. #2
    Join Date
    Feb 2003
    Posts
    417

    Re: Linkbutton does not look like a linkbutton

    It looks like the LinkButton cannot be databound. If it is, it just disappears. As a test, I tried this:

    Code:
    <asp:TemplateColumn HeaderText="Full Name">
    						<ItemTemplate>
    							<asp:LinkButton OnClick="dg_ItemCommand">
    								<%# DataBinder.Eval(Container.DataItem, "Full Name")%>
    							</asp:LinkButton>
    						</ItemTemplate>
    					</asp:TemplateColumn>

    The column displays the correct full name value but no underlining. I am guessing that the grid replaced the linkbutton with a literal control. I did this and found out.

    Code:
    lblMessage.Text = dg.Items(1).Cells(0).Controls(0).GetType.ToString
    in a button_click.


    Then, I tried this:

    Code:
    <asp:LinkButton id="lnk" style="Z-INDEX: 104; LEFT: 432px; POSITION: absolute; TOP: 80px" runat="server">The date and time is: <%# System.DateTime.Now.ToLongDateString %></asp:LinkButton>
    And it only showed the link button with the text

    The date and time is:


    How do I have a control in a grid that:

    (1) Is DataBound
    (2) Appears and acts like a linkbutton
    (3) Does not behave like the ItemTemplate's EditItem where you have those edit textboxes inside the grid itself.

  3. #3
    Join Date
    Mar 2005
    Location
    India
    Posts
    102

    Re: Linkbutton does not look like a linkbutton

    You can set the command name to select for the link button
    Like this:

    <asp:TemplateColumn>
    <ItemTemplate>
    <asp:linkbutton CommandName="Select" runat="server" "Linkbutton1" text='<%# DataBinder.Eval(Container.DataItem, "fullname") %>'>
    </asp:linkbutton> </ItemTemplate> </asp:TemplateColumn>
    codebehind:
    Private Sub DDL_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DDL.SelectedIndexChanged

    Dim Title As String = DDL.Items(DDL.SelectedIndex).Cells(1).Text

    lblmessage.Text = Title

    End Sub

    Now you will be able to see the linkbutton as a linkbutton,With an underline
    Hope that helps you!!

    -----------------------
    Rate me if you find this helpful

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured