You must Sign In to post a response.
  • Category: ASP.NET

    How to create Multiple dynamic Textbox and how to get & save they value into database

    hi Friends ,

    am doing a project like a job portal

    so education details are filled by the candidate
    i.e c.
    sslc , hsc,ug and pg
    sslc and hsc filled up normnal text boxes.
    but ug details is need add more

    1.Name of the College
    2.Branch
    3.Year of Passing
    4.Percentage/Grade
    if the candidate done diploma and ug he have to add .
    so neeed add more button or link .
    if candidate click the link na a new Column is populate with the Same 4 Fields.
    which is filled up by the candidate last time.
    in last i want a small Delete button or link. because if candidate added but he not needed that time he can able to delete the Column

    same requirement as pg is no problem .
    once i am done this on ug copy and paste to pg.

    So please friend please suggest me the best way to how i am done this task.

    i have to done it this requirement with in today .
    sorry for my inconvienence.
    thanks with
    Paul.S
  • #767892
    Hi,

    I assume that you are maintain this in one gridview control, in gridview we have different type of templates, for records display we are using ItemTemplate, for header we are using HeaderTemplate, but in your case along with above 2 templates you have to implement Footer for click Add new entry so you can use FooterTemplate, after implement this you can use gridview onrowcommand event for adding entries into database.


    Protected void gv_RowCommand(Object sender, GridViewCommandEventArgs e)
    {
    if(e.CommandName=="Add")
    {
    //add record into database
    }
    }


    once you add entry into database then on each row you have to implement one column for edit/delete an entry. while click delete button again you have to go back to gridview rowcommand event with command name delete,


    Protected void gv_RowCommand(Object sender, GridViewCommandEventArgs e)
    {
    if(e.CommandName=="Delete")
    {
    //delete record from database or inactive the record in database.
    }
    }


    Try something like above, it helps you to achieve your task.

    --------------------------------------------------------------------------------
    Give respect to your work, Instead of trying to impress your boss.

    N@veen
    Blog : http://naveens-dotnet.blogspot.in/

  • #767920
    i want wirhout gridview mr.neveen
    Paul.S

  • #767921
    Hai Paul Raj,
    There are many previous posts in our website where you can find the solution of your query. I am providing few links which you can refer and get the probable solution:

    1. http://www.dotnetspider.com/forum/344645-How-to-save-values-of-dynamic-textboxes-in-database-via-aspnet.aspx
    2. http://www.dotnetspider.com/forum/307861-How-save-dynamic-text-box-values-back-end.aspx
    3. http://www.dotnetspider.com/resources/750-Dynamically-creating-ASP-NET-controls-from-e-cod.aspx
    4. http://www.dotnetspider.com/forum/329862-How-add-keypress-event-textbox-aspnet.aspx

    Hope it will be helpful to you.

    Regards,
    Pawan Awasthi(DNS MVM)
    +91 8123489140 (whatsApp), +60 14365 1476(Malaysia)
    pawansoftit@gmail.com

  • #767930
    Hi,

    In that case you have to create one set of group and in that group you have to create controls dynamically as you want and while click on Add New row then create dynamic controls with full and different id and while click on save time add those records into database.

    --------------------------------------------------------------------------------
    Give respect to your work, Instead of trying to impress your boss.

    N@veen
    Blog : http://naveens-dotnet.blogspot.in/

  • #767949
    LoadViewState event is the key here, you need to create dynamic control and store its value in viewstate and finally save them in database see below snippet

    //define a new control class and add it in panel, see below snippet
    //Dynamic TextBox Panel

    pnlTextBox = new Panel();
    pnlTextBox.ID = "pnlTextBox";
    pnlTextBox.BorderWidth = 1;
    pnlTextBox.Width = 300;
    this.form1.Controls.Add(pnlTextBox);

    //button with handler
    //Button To add TextBoxes
    Button btnAddTxt = new Button();
    btnAddTxt.ID = "btnAddTxt";
    btnAddTxt.Text = "Add TextBox";
    btnAddTxt.Click += new System.EventHandler(btnAdd_Click);
    this.form1.Controls.Add(btnAddTxt);


    hope it helps

    Thanks
    Koolprasd2003
    Editor, DotNetSpider MVM
    Microsoft MVP 2014 [ASP.NET/IIS]


  • Sign In to post your comments