Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7368411
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T03:40:07+00:00 2026-05-29T03:40:07+00:00

Basically I am making a webform where you will fill all of the textboxes

  • 0

Basically I am making a webform where you will fill all of the textboxes out and then select a category from a dropdown and hit submit. Based upon which category you select should dictate what string the data from the textboxes is stored in. I’m on a novice level when it comes to C# and ASP.NET and something is off about my if statements but I can’t figure out how to do them properly.

Code below:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page
{
string non_fiction;
string fiction;
string self_help;



protected void Page_Load(object sender, EventArgs e)
{


}


protected void Submit_btn_Click(object sender, EventArgs e)
{
    if (Cat_DropDownList.SelectedIndex = 0)
    {
        fiction = "Title: " + Titletxt.Text + " | " + "Description: " + Descriptiontxt.Text + " | " + "Price: " + Pricetxt.Text + " | " + "Quantity: " + Quantitytxt.Text;
    }

    if (Cat_DropDownList.SelectedIndex = 1)
    {
        non_fiction = "Title: " + Titletxt.Text + " | " + "Description: " + Descriptiontxt.Text + " | " + "Price: " + Pricetxt.Text + " | " + "Quantity: " + Quantitytxt.Text;

    }

    if (Cat_DropDownList.SelectedIndex = 2)
    {
        self_help = "Title: " + Titletxt.Text + " | " + "Description: " + Descriptiontxt.Text + " | " + "Price: " + Pricetxt.Text + " | " + "Quantity: " + Quantitytxt.Text;
    }
}
}

Also to save another post I need to figure out a way to have these stored so I can call the “full” strings and add them to another one on another page.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T03:40:09+00:00Added an answer on May 29, 2026 at 3:40 am

    I would declare

    StringBuilder non_fiction = new StringBuilder();
    StringBuilder fiction = new StringBuilder();
    StringBuilder self_help = new StringBuilder();
    
    StringBuilder[] strings = null;
    

    and use them as

    protected void Page_Load(object sender, EventArgs e)
    {
        strings = new StringBuilder[] { fiction, non_fiction, self_help };
    }
    
    protected void Submit_btn_Click(object sender, EventArgs e)
    {
        strings[Cat_DropDownList.SelectedIndex].Append("Title: " + Titletxt.Text + " | " + "Description: " + Descriptiontxt.Text + " | " + "Price: " + Pricetxt.Text + " | " + "Quantity: " + Quantitytxt.Text);
    }
    

    without ifs and switches

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making a Stored Procedure that basically concatenates a long string with data from
I am basically making a video library where you download videos and I then
When I create a view I am basically making a new table that will
I would like to store equivalences from Connected-component labeling algorithm . It's basically making
i am making a small project which will be incorporated into larger project. basically
Basically I'm making an animated UI from scratch. Everything on the UI is derived
I am basically thinking of making a christmas gift got my girlfriend that will
So I'm basically making an app that adds a count to a number and
Okay, so I am basically making a script to pass post data using cURL.
I basically want to make things easier by just looping LinkButtons instead of making

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.