Solved

Call text input boxes from linkbutton

Posted on 2008-06-13
5
226 Views
Last Modified: 2010-05-18
What I have is an asp page that users can enter batch numbers.  They need the ability to enter multiple batch numbers or just one batch number.  So my thought was to place a link button on the screen that when they click on it , it adds another textbox to enter another batch number.  Then the last part of the question would be how do I get an id of the textboxes to add back into the databases.  
0
Comment
Question by:kdeutsch
  • 3
  • 2
5 Comments
 
LVL 21

Expert Comment

by:naspinski
ID: 21780568
an easier approach (imo) would be to have users type in multiple batch numbers into one textbox, seperated by commas, spaces, semicolons (whatever really).  Then you could easily get all the values using:

TextBox.Text.Split();

It also would avoid any postback or limiting of amount of numbers you could enter like the multiple textbox approach may cause.  Or are you stuck on multiple boxes?
0
 

Author Comment

by:kdeutsch
ID: 21780597
No not at all, enter in one place would be even better.  The thing that I guess I would need to more info on is the SQL insert statement.  We call out our connections from the common.vb so alls I have to do is a simple
Update  table  so on.
How would I go about updating a textbox described above using this insert method.
Thanks
0
 
LVL 21

Expert Comment

by:naspinski
ID: 21780672
This is the approach I would take:
string[] delimiters = new string[] { " ", ",", ";" };
string[] batches = txtBatches.Text.Split(delimiters, StringSplitOptions.RemoveEmptyEntries);
foreach (string s in batches)
    // insert into db
 
// your insert method would depend on how you access your DB
// Personally I like LINQ, but if youa re unfamiliar with that 
// I would say to go with the System.Data.SqlClient approach

Open in new window

0
 

Author Comment

by:kdeutsch
ID: 21781237
Ok here is the code I wrote but I am getting a lot of blue underlines.
The first is it says string is a class type and so not a valid expression,  foreach is not declared,
most of it is not declared statements.

Private Sub lnkSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkSubmit.Click

        string[] delimiters = new string[] { " ", ",", ";" };
        string[] batches = txtBatchNum.Text.Split(delimiters, StringSplitOptions.RemoveEmptyEntries)

        foreach (string s in batches)

        sql = "INSERT tblbatchNum (inTaskForceID, intUICid, strbatchNum) VALUES ('" & ddlTaskForce.SelectedValue & "', " _
                & "'" & DDLUIC.SelectedValue & "', '" & txtBatchNum.Text & "')"

        Response.Redirect("sadform.aspx")

    End Sub
0
 

Accepted Solution

by:
kdeutsch earned 0 total points
ID: 21874083
Solution,
I added a link button that after they put in a number they press on link its saved moved intot a listbox so they can see it and then they can enter other numbers.  1. this allows them to see what they enter right away and 2. solves my problem of entering multiple numbers while giving error correction in teh textbox.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question