Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. buttons on asp.net 2010 controls

buttons on asp.net 2010 controls

Scheduled Pinned Locked Moved ASP.NET
csharpasp-netquestiontutorialannouncement
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    classy_dog
    wrote on last edited by
    #1

    When working with a C#asp.net 2010 web forms, I am wondering if you can take the 'buttons' out of a control and place them somewhere else on the webform and still have them work? I would want those buttons to still refer to the asp.net control that they were originally associated with? I am referring to buttons like insert, delete, and update. In particular I am asking that question about the listview, formview, or detailview control? If this is possible, I am wondering if you can tell how how to accomplish this task and/or point me to a url that I can use as a reference to complete this task? In addition when working with the buttons within the web form application and preferably not within the asp.net control, can I perform other programming that needs to occur? If so, can you tell point how this would be accomplished? Would I need to put the code in a certain method like a page_load,pre_init, a certain click event?

    H 1 Reply Last reply
    0
    • C classy_dog

      When working with a C#asp.net 2010 web forms, I am wondering if you can take the 'buttons' out of a control and place them somewhere else on the webform and still have them work? I would want those buttons to still refer to the asp.net control that they were originally associated with? I am referring to buttons like insert, delete, and update. In particular I am asking that question about the listview, formview, or detailview control? If this is possible, I am wondering if you can tell how how to accomplish this task and/or point me to a url that I can use as a reference to complete this task? In addition when working with the buttons within the web form application and preferably not within the asp.net control, can I perform other programming that needs to occur? If so, can you tell point how this would be accomplished? Would I need to put the code in a certain method like a page_load,pre_init, a certain click event?

      H Offline
      H Offline
      Hanzaplast
      wrote on last edited by
      #2

      if i understand, you want to preform update, insert, delete functions from other location rather than inside common asp.net grid controls like ListView, FormView, DetailsView... it can be done easily. you just need to call function you want to preform for target control. this is example how to call Update function for FormView outside of FormView

      <asp:FormView runat="server" ID="fv" DefaultMode="Edit" DataKeyNames="id" OnItemUpdating="fv_ItemUpdating">
      <EditItemTemplate>
      <asp:TextBox runat="server" ID="tb" Text='<%#Bind("name") %>' />
      <asp:Button runat="server" ID="btn" Text="Edit Inside" CommandName="Update" />
      </EditItemTemplate>
      </asp:FormView>

      <asp:Button runat="server" ID="btn" Text="Edit Outside" OnClick="EditOutside" />

          public System.Data.DataTable SomeData()
          {
              System.Data.DataTable temp = new System.Data.DataTable();
              temp.Columns.Add("id");
              temp.Columns.Add("name");
      
              System.Data.DataRow dr = temp.NewRow();
              dr\["id"\] = 1;
              dr\["name"\] = "somebody";
              temp.Rows.Add(dr);
              
              dr = temp.NewRow();
              dr\["id"\] = 2;
              dr\["name"\] = "someone";
              temp.Rows.Add(dr);
              return temp;
          }
          protected void Page\_Load(object sender, EventArgs e)
          {
              if (!Page.IsPostBack)
              {
                  fv.DataSource = SomeData();
                  fv.DataBind();
              }
          }
          public void fv\_ItemUpdating(object sender, FormViewUpdateEventArgs e)
          {
              string txtValue = (fv.FindControl("tb") as TextBox).Text;
          }
          public void EditOutside(object sender, EventArgs e)
          {
              fv.UpdateItem(false);
          }
      
      C 1 Reply Last reply
      0
      • H Hanzaplast

        if i understand, you want to preform update, insert, delete functions from other location rather than inside common asp.net grid controls like ListView, FormView, DetailsView... it can be done easily. you just need to call function you want to preform for target control. this is example how to call Update function for FormView outside of FormView

        <asp:FormView runat="server" ID="fv" DefaultMode="Edit" DataKeyNames="id" OnItemUpdating="fv_ItemUpdating">
        <EditItemTemplate>
        <asp:TextBox runat="server" ID="tb" Text='<%#Bind("name") %>' />
        <asp:Button runat="server" ID="btn" Text="Edit Inside" CommandName="Update" />
        </EditItemTemplate>
        </asp:FormView>

        <asp:Button runat="server" ID="btn" Text="Edit Outside" OnClick="EditOutside" />

            public System.Data.DataTable SomeData()
            {
                System.Data.DataTable temp = new System.Data.DataTable();
                temp.Columns.Add("id");
                temp.Columns.Add("name");
        
                System.Data.DataRow dr = temp.NewRow();
                dr\["id"\] = 1;
                dr\["name"\] = "somebody";
                temp.Rows.Add(dr);
                
                dr = temp.NewRow();
                dr\["id"\] = 2;
                dr\["name"\] = "someone";
                temp.Rows.Add(dr);
                return temp;
            }
            protected void Page\_Load(object sender, EventArgs e)
            {
                if (!Page.IsPostBack)
                {
                    fv.DataSource = SomeData();
                    fv.DataBind();
                }
            }
            public void fv\_ItemUpdating(object sender, FormViewUpdateEventArgs e)
            {
                string txtValue = (fv.FindControl("tb") as TextBox).Text;
            }
            public void EditOutside(object sender, EventArgs e)
            {
                fv.UpdateItem(false);
            }
        
        C Offline
        C Offline
        classy_dog
        wrote on last edited by
        #3

        Thanks! that is exactly what I want to do!

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups