Re: Simple question - making a button visible in template.

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



On Tue, 16 May 2006 11:05:17 -0400, "Phillip Vong"
<phillip_vong*at*yahoo*dot*com> wrote:

Beuller / Beuller?


"Phillip Vong" <phillip_vong*at*yahoo*dot*com> wrote in message
news:OyI0GBFeGHA.3632@xxxxxxxxxxxxxxxxxxxxxxx
NEWBIE trying to learn.

Have a simple table and I am using VS2005. I created the formview and I
turned on Update/Insert/Delete. In the Update template, I made the
"UPDATEBUTTON" (ID) not visible. I gave that link a new text of "Confirm
Update". I added a Button1 and gave it a text of "Update". I want the
Button1_click to make the UpdateButton (ID) visible.

I basically want people confirm they want to update before they are
allowed to do so.

I have attached the actual code. Can someone tell me how I can make the
UPDATEBUTTON visible?

I know how to do it when it's not in form view with "control.visible =
true", but I can not get it to work in this format.

Thanks!

Phil / newbie




You would add a new link button to the formview as follows:

....
<asp:LinkButton ID="LinkButtonTurnOnUpdate" Text="Turn On Edit"
Visible="true" runat="server">LinkButton</asp:LinkButton>
<asp:LinkButton ID="EditButton" runat="server"
CausesValidation="False" Visible="false" CommandName="Edit"
Text="Edit">
</asp:LinkButton>
<asp:LinkButton ID="DeleteButton" runat="server"
CausesValidation="False" CommandName="Delete"
Text="Delete">
</asp:LinkButton>
<asp:LinkButton ID="NewButton" runat="server"
CausesValidation="False" CommandName="New"
Text="New">
</asp:LinkButton>
</ItemTemplate>

Then, add an ItemCommand Event to the codebehind class like the
following. Then, when you click the new button, it will make visible
the edit button.

protected void FormView1_ItemCommand(object sender,
FormViewCommandEventArgs e)
{
LinkButton editLinkButton =
FormView1.FindControl("EditButton") as LinkButton;
editLinkButton.Visible = true;

}

Peter Kellner
http://peterkellner.net
.


Quantcast