TemplateField problem

Last post 10-01-2006 4:30 AM by Fredrik N. 1 replies.

Sort Posts:

  • TemplateField problem

    09-30-2006, 9:27 PM
    • Loading...
    • khilo
    • Joined on 10-01-2006, 1:14 AM
    • Posts 1

    Sorry I am new to ASP, I am trying to control the visibility of a LinkButton in a GridView based on two condition 

    first is the row in edit state

    second is the cell next to it is full and not empty, I have this templateField but I don't know how to pass the row Index to decide whether I want to show the linkButton or not. 

    <ItemTemplate>

    <asp:Panel ID="Mypanel" runat='server' Visible=' getVisible("here I want to pass the row index")#

    E<asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Delete"

    OnClientClick='return confirm("Are you sure you want to delete this entry?");'

    Text="Clear Translation" />

    </asp:Panel>

    </ItemTemplate>

    </asp:TemplateField>

    Please if you can help me solve this problem, I will be gratefull

    thank you in advance..

  • Re: TemplateField problem

    10-01-2006, 4:30 AM
    • Loading...
    • Fredrik N
    • Joined on 06-22-2002, 1:03 AM
    • Sweden
    • Posts 5,333
    • Moderator
      TrustedFriends-MVPs

    I should probably use the RowDataBound event and check the value of the next column.

    I think this post can give you some ideas: http://fredrik.nsquared2.com/viewpost.aspx?PostID=237

    You can either programatically add the LinkButton or remove the LinkButton for each row (I should probably add it from the RowDataBound event to the column.

    You can check what state the row has by using the RowState property of he DataRow object. (In the post I liked to you above, will get the current row that is databind, and from that row you can get the state).

    If you want to show different controls based on the Row state, you can also add a EditItemTemplate (the control inside this template will be displayed when the row is in edit mode).

     

    /Fredrik Normén NSQUARED2
    Microsoft MVP, MCSD, MCAD, MCT

    ASPInsiders
    My Blog, ASP.Net 2.0 etc

    Cornerstone AB
Page 1 of 1 (2 items)
Microsoft Communities
Page view counter