Need Help its Urgent pleazzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz

Last post 01-18-2007 10:35 AM by ecbruck. 1 replies.

Sort Posts:

  • Need Help its Urgent pleazzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz

    01-18-2007, 1:23 AM
    • Member
      2 point Member
    • khalidsohail
    • Member since 01-04-2007, 12:52 PM
    • Posts 7

    Protected Sub ItemDB(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs)
            If CInt(ViewState("tot")) = 1 Then
                If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then
                    Dim btn As Button = CType(e.Item.Cells(10).FindControl("delBtn"), Button)
                    btn.Visible = False
                End If

            End If
        End Sub

    this will hide the delete button if the i have one recored in data grid this code works well now when i click the edit button then the delete again show so tell me where should i write the code that will hide the delete button again because its not needed.

     

    thanx in advance 

  • Re: Need Help its Urgent pleazzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz

    01-18-2007, 10:35 AM
    • All-Star
      86,764 point All-Star
    • ecbruck
    • Member since 12-30-2005, 2:39 PM
    • Des Moines, IA
    • Posts 9,209
    • Moderator
      TrustedFriends-MVPs

    Here's a small example that might help you:

    ASPX 

    <asp:datagrid id="dgProducts" runat="server" datasourceid="sdsProducts">
    	<columns>
    		<asp:templatecolumn>
    			<itemtemplate>
    				<asp:linkbutton id="btnDelete" runat="server" commandname="Delete" text="Delete"
    					visible='<%# CanDelete() %>' />
    				</itemtemplate>
    		</asp:templatecolumn>
    	</columns>
    </asp:datagrid>
    <asp:sqldatasource id="sdsProducts" runat="server" connectionstring="<%$ ConnectionStrings:NorthwindConnectionString %>"
    	selectcommand="SELECT * FROM [Products]">
    </asp:sqldatasource>

    CODE-BEHIND 

    protected bool CanDelete()
    {
    	// Put any condition you want here simply
    	// returning true if you want the button
    	// visible or false if not
    	return false;
    }

    Thanks, Ed

    Microsoft MVP - ASP/ASP.NET

Page 1 of 1 (2 items)