Can I use the same textbox in for searching of name and inserting it if it's new in webform?
if yes how?
Note: I already have the write procedure for searching and also stored procedure for adding the name for DB.
thanks in advanced
Can I use the same textbox in for searching of name and inserting it if it's new in webform?
if yes how?
Note: I already have the write procedure for searching and also stored procedure for adding the name for DB.
thanks in advanced
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Naimish MakwanaRank #324 · 7.7K reputationPosted Mar 3, 2023, 10:52 AM EST
Hello Name,
One way to achieve this is by implementing a search functionality that checks whether the entered name already exists in the database. If it does, the search results can be displayed to the user. If it doesn't exist, the textbox can be used to insert the new name into the database
Second way you can add a dropdown list which is having option to search or insert. Based on selection you can perform the optration.
Thanks
Naimish Makwana
Name Mame164 reputationPosted Mar 3, 2023, 11:03 AM EST
@Naimish Makwana
thanks
can you help in in the code ? for implement the first way?
Naimish MakwanaRank #324 · 7.7K reputationPosted Mar 3, 2023, 11:10 AM EST
you can implement the search and add functionality using a single button.
then add btnSubmit_Click event
protected void btnSubmit_Click(object sender, EventArgs e) { string name = txtName.Text; // Call the search procedure to check if the name exists in the database bool nameExists = SearchName(name); if (nameExists) { // Display search results to the user lblResult.Text = "Name found!"; } else { // Call the stored procedure to add the new name to the database bool nameAdded = AddName(name); if (nameAdded) { // Display a message indicating that the name was added successfully lblResult.Text = "Name added successfully!"; } else { // Display an error message if the name could not be added to the database lblResult.Text = "Error adding name!"; } } }Sam HobbsRank #107 · 20.5K reputationPosted Mar 4, 2023, 11:45 AM EST
Arvind YadavRank #880 · 2.5K reputationPosted Mar 5, 2023, 5:40 AM EST
for searching and inserting keep both text boxes separate.