0

I have one of the tables with the attributes: id, class name, student name. I want to enter data 1 class name with many student names with 2 textboxes. 1 Textbox is used for class names, 1 textbox for student names. For the student's name textbox, I enter names by separating them with "," each name. How to overcome this problem? Are there other ways to fix this problem? thanks.

Model Classroom.cs

public partial class Classroom
{
        public int id { get; set; }
        public string class_name { get; set; }
        public string student_name { get; set; }
}
2
  • What's the problem you are facing? You need to split the Text of StudentName textbox by "," , that will give you array of student names. Loop thru the array and execute insert query for all the studentnames. Commented Jan 29, 2020 at 7:08
  • You need to design your model in a way that will adhere to your required functionality. You can have something like a List<Classroom> defined in a view-model that will hold the values. Commented Jan 29, 2020 at 7:09

1 Answer 1

1

You can do YourStringName.split(",") this will return you a String Array with your values you had seperated with your comma but it is very dirty. I would Prefer to use for each Student a singel button click that adds the student to a list of Classroom and add them together to database.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.