How to programmatically in invoke a button click event for a button inside a Formview?

Hi, my name is Bonfa', would like to invoke a button click event programmatically in, but the button is inside a formview, how can i accomplish this?

I was trying to do like this FormView1.FindControl("btn_update_click.PerformClick()") but it is not working.

Thanks in advance.

10/10/2008 11:23:43 AM 72751 articles. 3 followers. Follow

5 Replies

Similar Articles

[PageSpeed] 43
Get it on Google Play
Get it on Apple App Store


In the markup you can do this:

 <asp:Button ID="btnUpdate" runat="server" Text="Update" OnClick="btnUpdateClick" />

Then in the code behind you can write your sub:


Protected Sub btnUpdateClick()
     'your code here              
End Sub
10/10/2008 2:56:36 PM

Hi bonfa ,

Just like may.23.2007 has said, the button has an event hanlder which will be executed when you click that button.

So if you want to invoke a button click event programmatically , you just need to invoke that event handler manually.


Samu Zhang
Microsoft Online Community Support

Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question.
10/13/2008 8:38:23 AM

Hi guys, the thing is i got button1, when i click button 1 the following code will get executed, but i want call another button now the BTN_UPDATE on click event at the end of the button1 click code that is inside a formview but is not working.


Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        'Extended fields Update
        Dim tbheight As TextBox = FormView2.FindControl("tbheight")
        Dim TBWIDTH As TextBox = FormView3.FindControl("TBWIDTH")
        Dim TBDIAMETER As TextBox = FormView4.FindControl("TBDIAMETER")
        Dim TBDEPTH As TextBox = FormView5.FindControl("TBDEPTH")
        Dim TBCOLOUR As TextBox = FormView6.FindControl("TBCOLOUR")
        Dim TBFINISH As TextBox = FormView7.FindControl("TBFINISH")
        Dim TBADD1 As TextBox = FormView8.FindControl("TBADD1")
        Dim TBADD2 As TextBox = FormView9.FindControl("TBADD2")
        Dim TBADD3 As TextBox = FormView10.FindControl("TBADD3")
        'Dim tbBar_Code As TextBox = FormView1.FindControl("tbBar_Code")
        'Dim tb_error As TextBox = FormView1.FindControl("tb_error")
        objConn = New SqlConnection(strConnection)
        strSql1 = "UPD_PDXT_FIELDS"
        Dim myCommand1 As New SqlCommand(strSql1, objConn)

        myCommand1.CommandType = Data.CommandType.StoredProcedure
        myCommand1.Parameters.AddWithValue("ID", Request.QueryString("Product_ID"))
        myCommand1.Parameters.AddWithValue("HEIGHT", tbheight.Text.ToString)
        myCommand1.Parameters.AddWithValue("WIDTH", TBWIDTH.Text.ToString)
        myCommand1.Parameters.AddWithValue("DIAMETER", TBDIAMETER.Text.ToString)
        myCommand1.Parameters.AddWithValue("DEPTH", TBDEPTH.Text.ToString)
        myCommand1.Parameters.AddWithValue("COLOUR", TBCOLOUR.Text.ToString)
        myCommand1.Parameters.AddWithValue("FINISH", TBFINISH.Text.ToString)
        myCommand1.Parameters.AddWithValue("ADD1", TBADD1.Text.ToString)
        myCommand1.Parameters.AddWithValue("ADD2", TBADD2.Text.ToString)
        myCommand1.Parameters.AddWithValue("ADD3", TBADD3.Text.ToString)

        'myCommand1.Parameters.AddWithValue("TaxGroup", tbProduct_Tax_Group.Text)
        'myCommand1.Parameters.AddWithValue("barCode", tbBar_Code.Text)
        'myCommand1.Parameters.AddWithValue("errorDesc", tb_error.Text)
        'myCommand1.Parameters.AddWithValue("brand", ddBrand.Text)
        'myCommand1.Parameters.AddWithValue("published", cbPublished.Checked.ToString)

        Catch ex As Exception
        End Try

        FormView1.FindControl("btn_update_click.PerformClick()")  --- How can i call the BTN_UPDATE on click event

that is inside a formview???

    End Sub

10/13/2008 8:51:25 AM


Hi, my name is Bonfa', would like to invoke a button click event programmatically in, but the button is inside a formview, how can i accomplish this?

I was trying to do like this FormView1.FindControl("btn_update_click.PerformClick()") but it is not working.

Thanks in advance.

here is a sample code for u

aspx page

  <asp:FormView ID="FormView1" runat="server" DataSourceID="SqlDataSource1" DefaultMode="Edit">
                <asp:CheckBox ID="InTheatersCheckBox" runat="server" Checked='<%# Bind("InTheaters") %>' OnCheckedChanged="InTheatersCheckBox_CheckedChanged" AutoPostBack="True" /><br />
                <asp:TextBox ID="TitleTextBox" runat="server" Text='<%# Bind("Title") %>'>
                </asp:TextBox><br />
                <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update"
                <asp:LinkButton ID="UpdateCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
                <asp:CheckBox ID="InTheatersCheckBox" runat="server" Checked='<%# Bind("InTheaters") %>' /><br />
                <asp:TextBox ID="TitleTextBox" runat="server" Text='<%# Bind("Title") %>'>
                </asp:TextBox><br />
                <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" CommandName="Insert"
                <asp:LinkButton ID="InsertCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
                <asp:CheckBox ID="InTheatersCheckBox" runat="server" Checked='<%# Bind("InTheaters") %>'
                    Enabled="false" AutoPostBack="True" OnCheckedChanged="InTheatersCheckBox_CheckedChanged" /><br />
                <asp:Label ID="TitleLabel" runat="server" Text='<%# Bind("Title") %>'></asp:Label><br />

codebehind page

  protected void InTheatersCheckBox_CheckedChanged(object sender, EventArgs e)
        if (FormView1.CurrentMode == FormViewMode.Edit)
            CheckBox chk = (CheckBox)FormView1.Row.Cells[0].FindControl("InTheatersCheckBox");
            if (chk.Checked == true)
                TextBox tb = (TextBox)FormView1.Row.Cells[0].FindControl("TitleTextBox");
                Session["title"] = tb.Text;
                tb.Text = "";
                TextBox tb = (TextBox)FormView1.Row.Cells[0].FindControl("TitleTextBox");
                tb.Text = (string)Session["title"];

Jai Ganesh. J , GSD ,India

Please Mark As Answer If my reply helped you.
10/13/2008 10:48:26 AM

hi bonfa,

try this..


to call "btn_update_click" event..

Rahul Somwanshi,
Software Engineer,
Pune, India.

If this is a right answer to your question then,
do not forgot to ckick on "Mark As Answer"
10/13/2008 11:03:14 AM

Similar Artilces:

How do I invoke the button's click event using using VB.Net
I am programming VB.Net for my project. Can anyone tell me how do I code the "button" server control to invoke the click event? I believe one line of VB code would do. It didn't work when I try btnButton.Click() ???? Thank You! You can always call btnButton_Click(Me, EventArgs.Empty) If I remember correctly. This assumes you have a btnButton_Click(sender as Object, e as EventArgs) sub somewhere in your page. Greg You can also do btnButton_Click.PerformClick() !Jarod Sorry... Forget... The PerformClick method exist only for windows forms b...

How to call button click event in VB.Net?
Hi All,         I have a button(button1) which has some line of code to be executed it its click.         I want to execute all those lines of code in some other  button click(button2).         I want to make use of the button event(button1) without writing the whole lines of code in the button(button1)       Example:::          button1_click(some arguments) { line 1; line 2 line 3; line 4; } I have another ...

ISSUE WITH Control's behaviour inisde UPDATE PANEL
 hii evry1..,             i have an strange chk it out..                      aspx page:            < asp:UpdatePanel ID="OUpdatePanel" runat="server" >                <ContentTemplate>             &nbs...

.net Button Clicked Event
In powerbuilder the Button Clicked Event passes ID and Row information in the event args - I cannot find thes in the button clicked args of Datawindow .net is this correct? Am I missing something? if not how can I get this info int the button clicked event? Thanks Please notify in which environment you are running, Webform or WinForm. In case of Webform you get it at the client side after initializing the ClientEventButtonClicked event. Yossi Dallal <Gerry Sliz> wrote in message > In powerbuilder the Button Clicked Event ...

Pls Help: Inheritance Control declared in aspx: Button Event firing! Inheritance control created programmatically: buttons NOT Firering
Hello all,Facing a problem again hope u can help me out:Control:   [Serializable] public class HeaderField { public string HeaderText { get; set; } public bool NotSortable { get; set; } public string SortExpression { get; set; } public HeaderField(string text, string sortExp) { HeaderText = text; SortExpression = sortExp; } } public class EviSorterCommandEventArgs : CommandEventArgs { public string Message { get; set; } public EviSorterCommandEventArgs(string message, CommandEventArgs origi...

I double click a button but no event handle in source view why, go to button properties,events,onclick, try to create event handle but its where. Only the button markup.
I have a button, if double click it no handle is created. Iam only taken to the buttons' markup in source view. This is happening on all pages through out the whole solution. Possible cause is, this project was not ajax enabled, i installed ajax, edited the web.config file of this project to make the site ajax enabled. I had to build the solution and got no errors, every thing is ok a part from double clicking all controls not being able to get to their event handles.--------------------------------------------------No Project Too Eazy.-------------------------------------------------- ...

how to create button controls dynamically .. then i need that click event of buttons
how to create button controls  dynamically .. then i need that click event of buttons  urgent ???????Vino  Add dynamic controls with eventsWebsite Design Darlington - - Experts, Information, Ideas & Knowledge - An online resource for professional ASP.NET developersPlease remember to click "Mark as Answer" on this post if it helped you refer below snippet..public partial class _Default : System.Web.UI.Page {    protected void Page_Load(object sender, EventArgs e)  ...

Using a button to execute the IE Back Button
I have a form that users submit information about a list they are viewing we'll call it userview page for this post. When someone is viewing the userview page they look at a list and click on an item on the list they want to comment about.When they click on an item it takes them to a page with a text box to put comments about the item etc. then the user will hit submit and add a comment.  (I want to use VB.NET to accomplish this..)How can I make the submit button to execute the back button on the IE browser twice?That way it returns the user to the exact place they were on their list. T...

Access formview controls on button click event
 I have a formview with a label. I want to change the text of the label when the user clicks:dim  x  as label = CType(editProfileFormView.FindControl("userErrLabel"), Label)                              x.Text = "hello" The assigment changes the text on Page_load but it doesnt do anything if i put it in Button1_click event. How can i change the text on the click event?        &nbs...

Button click event vs button command event
Hi, Can any one tell me whats the difference between the two events, and when to use which one? Thanks. Check out this article on event bubbling: Bubbling Events Up the Control Hierarchy Summary: The DataGrid control, as you likely know, can easily be configured to add a column of buttons. By adding a ButtonColumn, whenever one of the DataGrid's buttons in the column is clicked, the Web page posts back and the DataGrid's ItemCommand event fires. In fact, the same behavior can be noted if you manually add a Button or LinkButton control into a DataGrid TemplateColum...

How to call click event of button apart from clicking on the button.
I want to call click event event of my button and run codes within the event, not clicking on the button itself. For instance in Page_Load event of my page i want to call it. How can i handle this? Thanks in advance. Hi, Try this  Protected Sub form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles form1.Load If Not IsPostBack Then Me.Button1_Click(sender, e) End If End Sub Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click Response.Write("Hello World!!!") End Sub  ...

button click event from another button click not firing
 Hi,  I want to trigger a button click event from another button click .It is not firing.  Please help.  protected void btnReview_Click(object sender, EventArgs e) {       if (MandatoryValidation())        {         this.Button1.Click += new System.EventHandler(this.Button1_Click);       } }protected void Button1_Click(object sender, EventArgs e) { } protected void btnReview_Click(object sender, EventArgs e){            if (MandatoryValidation())     {        this.Button1.Click += new System.EventHandler(this.Button1_Click); //The event is registered not called.        Button1_Click(null, null);      } }protected void Button1_Click(object sender, EventArgs e) { }Hope that helps  Techie (.Net Knowledge at its Best)We make a living by what we get, but we make a life by what we give.::: Winston Churchill :::  protected void btnReview_Click(object sender, EventArgs e) {       if (MandatoryValidation())        {         Button1_Click(null,null);       } }protected void Button1_Click(object sender, EventArgs e) { }Kamran...

Question on how to wire up events to a server button(VB.NET)
Ok I have a datagrid.Using a templete column I can and my server button to the rows correctly.I need to know how to wire up and get it to work for my event handler.How is this done so it works.I get the button to post back but the event never fires.Can someone show me how this done so it will work? Can you post up your event code? It's hard to work out what you're wanting fixed when we can't see the problem. Are you using EditCommand or SortCommand? - VB.NET, C#, Silverlight, Javascript, HTML, CSS, T-SQL, MySQL and - Gaming News and Review...

Button Control to fire off my VB.NET console exe
I have a requirement to allow a user to fire off some console code, a process I created to run some stuff for them...parsing out a txt file etc.  Is there a way to tell an web control to run an a console exe?When is Microsoft going to get rid of VB.NET! You can use the ProcessClass and Process.Start.  However, this account that is running ASP.NET might not have enough permissions to do this so you may need to impersonate or upgrade the priveledge levels of the ASP.NET account.  You can also consider some remoting solutions: Here's some doc's on the process class: remoting docs: --Dannydisclaimer: Information provided is 'as is' and conveys no warranties or guarantees....

On_Click event for buttons will not work in
Whenever I add a button to a form/project in Visual Studio/ And run when the button is clicked nothing happens. Thos if I run the code speratly in a <script> </script> file by itself everything executes fine and the onclick event works. here is aforum where I posted my code for one particular form which is having this problems (any time i use a button it wont work unless is <script tags> I have build the project many times and has no errors. please help visit for my code Visit #1 Windows Vista Fo...

calling given javascript script from button click
Respected membersCan anybody please help me to call the script given below after button click    The script below displays google map on normal html page.when i tried using ClientScript.RegisterStartupScript , iam getting error on line 7 missing ; errorIf you can provide the modified code i'll be grateful to u.Thanks in advance<script src=";v=2&amp;key=ABQIAAAAGmS6k6UngyTjN0Lp26Kk5xQpTR6YCxnSXrgb0dAWLhf5sIEOjRResgehB9eed2b9p_qltU3hRBfG4g"      type="text/javascript"></script>    <script type="text/javascript">    //<![CDATA[    function load() {      if (GBrowserIsCompatible()) {        var map = new GMap2(document.getElementById("map"));        map.setCenter(new GLatLng(-30,90), 1);var point = new GLatLng(-30,90);var marker = new GMarker(point);map.addOverlay(marker);      }    }    //]]>    </script>  </head>  <body onload="load()" onunload="GUnload()">    <div id="map" style="width: 1024px; height: 840px"></div>  </body> I see nothing really wrong with the JavaScript. Add this to your Page_Load eve...

[VB .NET] Changing Gridview Field Type with Button Click
Hi,I have a Gridview with a Template Field and Text Box showing a value. What I would like to do is change this to a Bound Field when the user clicks on a button. Any ideas how to do this?Thanks Hi, Why do you want to convert the Template Field to the Bound Field? Based on my understandings, you may want to display the text in the label instead of the TextBox. If so, we could put both of the TextBox and Label(the visible is false initially)  to the Template. When we click the button, then the visible of the TextBox will be false and that of the Label will be...

Sending SMS using or using or
Hi  My requirement is I hav one csv file with these fields id,mobilenum,messgae,status.intiallu staus is 0. once i read the all fileds and take that mobile number.using tat mobile number  i need to send sms .after sending sms i shuld change status as 1 How to send sms thru coding (please dont provide any links.if it is provide also please give working links becox i checked codeproject .i didnt get any nice link. and also provide the how to update the status field im csv file   Thank ssandhya   To send SMS, you need some third party SMS providers. if you consul...

How I can accede to the controls that they find inside a formview from VB.NET
Hi again: How I can accede to the controls that they find inside a formview, to use its values, to modify or validate it, from  VB.NET. For example I have the next page Items.aspx: <table border="0" cellspacing="0" cellpadding="0">     <tr>        <td><asp:TextBox runat="server" ID="MinIDProducto" Text="" /> </td>        <td></td>     </tr>     <tr>        <td><asp:Tex...

doesn't fire button click event while button is binding with Model popup control
Hi, I have created using asp:button control as TargetControlID  for Modal PopUp control. I  want to run some code on btn_click event also. but after using this button with model popup  control not firing btn_click() Event. <asp:ImageButton id="btn_buy" ImageUrl="~/Images/ShoppingItemImage/btnbuyred.gif" runat="server" OnClick="btn_buy_Click"></asp:ImageButton> and Model Popup <cc1:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="btn_buy1" PopupControlID="pnl_user" DropShadow="true" >             </cc1:ModalPopupExtender> Please remember to mark the replies as answers if they help .Jeetendra SharmaSoftware EngineerJodhpur (Raj.)India HI  U make   TargetControlID="btn_buy" instead of   TargetControlID="btn_buy1"  Try this..              HI Happy SmilingRegardsKarthikeyan Hi, I did that for debugging only. I used btn_buy . But Problem is not  resolved  Please remember to mark the replies as answers if they help .Jeetendra SharmaSoftware EngineerJodhpur (Raj.)India  If you want to fire some server side code before showing the modal popup, you are better off using theMod...

link button Command argument value lost when iam clicking on cancel button inside formview
Hi all, i have added linkbutton dynamically to table server control on linkbutton click iam calling assocaited data detail inside formview control but when iam clicking on cancel button inside formview , formview become visible = false . but when iam clicking linkbutton again  nothing is displaying inside formview . what would be the problem. please share me ideas. I have passed command argument value to button click .    Best regards Rameezwaheed life is name of learning!Mark as an answer if it helps Hi Rameezwaheed, Not quite sure what the issue is, but you need to r...

Dynamically loaded user control with a button doesn't fire its button click event?
I have a datagrid, in which one of the columns is 'button' column called 'Send Email'. When I click on this button, then an email user control is dynamically loaded into a placeholder above the datagrid header area. The email control renders correctly, but when I click on 'Send' button in this user control, then the click event of this 'Send' button doesn't fire. This is even though the 'Handles.btnSend.Click' is there for the click method of the 'Send' button. Can someone please tell me why the event is not firing and what do I need to do to make it fire?    sun21170 you have...

On enter
 I'm using .net 1.1. My content page is inside a template. There is a submit button in the template and in my page. When the user presses enter key, the button click event in the template page is firing. How do I force my button click event to fire on enter? I googled it and found a fix that if I add an input control it should fix it. But it didn't. Are there any other solutions? Here is my page's code. i don't have the template code.<form runat="server" id="FormDonor" method="post">          &nb...

How to download all file on one button click event or link button event
 Hai,          My problem is like that actually what i have to do,         I have five download link and i want to download all that five files on single button click.         File1.txt  File2.txt File3.txt File4.txt File5.txt           Button1       If i click to button then all files should be downloaded. Please help me you cannot download multiple files. each download is for a single file only.  that's all the browser w...

Web resources about - How to programmatically in invoke a button click event for a button inside a Formview? -

[...] How to Programmatically Administer Off-Facebook Pages with the Open Graph API - Inside Facebook ...
With the Open Graph protocol that Facebook announced at last week’s f8 conference, any URL can now be treated just like a Facebook Page. After ...

Well, This Is Different Time Inc. Now Selling Print Ads Programmatically
Machines are now selling some print ads at Time Inc. The nation's largest magazine publisher owner of People, Time, Sports Illustrated and InStyle ...

Time Inc. Sells Print Ads Programmatically
Time Inc. is stepping into the future of advertising. The company is now allowing advertisers to use programmatic advertising — the buying and ...

Wesabe makes Financial Data available programmatically
Wesabe has just done what I've been trying to convince banks to do for years. They're making financial data available via a simple POX (Plain ...

MarTech Today: Amplitude’s Compass, deep dive into beacons & most marketers buy programmatically
Here’s our daily recap of what happened in marketing technology, as reported on Marketing Land and other places across the web. From Marketing ...

IPG Begins Buying Local Broadcast Programmatically: Can Target, Retarget Viewers In Near Real-Time
In what likely is the most significant development yet to bring programmatic media-buying to local broadcast television, Interpublic's Mediabrands ...

Google Launches Cloud SQL API To Allow Developers To Manage Their Databases Programmatically
... to use Google’s admin interface. Today, however, Google is launching the Cloud SQL API . This new REST API will allow developers to programmatically ...

Are Programmatically Purchased Native Ads Native Enough?
It seems everyone and their mothers are pushing native ad units and tools to support them. Facebook, Twitter, Yahoo and most recently AOL all ...

AT&amp;T Plans to Sell Linear TV Programmatically
AT&T plans to start selling linear TV ads on cable networks on U-verse and DirecTV via automated software later this year as part of a partnership ...

Most Major U.S. Publishers Now Sell Ads Programmatically
Most major online publishers in the U.S. now sell at least some of their ad space using automated "programmatic" technology, according to new ...

Resources last updated: 3/9/2016 9:04:13 AM