This topic is locked
[SOLVED]

 multiple selection

12/8/2017 6:09:02 AM
ASPRunner.NET General questions
K
kleanthis author

How I can have 'multiple selection' and to insert the values in the table in different rows?

T
Tim 12/8/2017

Is this what you mean:
https://xlinesoft.com/asprunnernet/docs/select_multiple_values.htm
If not, please provide more details about what you're trying to do.
Thanks,

Tim

K
kleanthis author 12/8/2017

Dear Tim

this is the screen shot from my add page


and this is the code that I used



if (values["UserId"])

{

var arr = MVCFunctions.explode(",", values["UserId"]);

// This is the name of the multi check box or

// list select field, its value becomes arr



for (int i = 0; i < arr.Count(); i++)

{

var strInsert = String.Format("insert into DDK_Student (UserId) values ('{0}')", arr[i]);



var strInsert3 = String.Format("insert into DDK_Student (Draseis) values ('{0}')", arr[i]);

var strInsert4 = String.Format("insert into DDK_Student (Perigrafi) values ('{0}')", arr[i]);

var strInsert5 = String.Format("insert into DDK_Student (Monades) values ('{0}')", arr[i]);

var strInsert6 = String.Format("insert into DDK_Student (TimeStamp) values ('{0}')", arr[i]);

var strInsert7 = String.Format("insert into DDK_Student (Class) values ('{0}')", arr[i]);

var strInsert8 = String.Format("insert into DDK_Student (UserIdTeach) values ('{0}')", arr[i]);
// add more fields from the add page to be inserted into database

CommonFunctions.db_exec(strInsert, GlobalVars.conn);

}



// Exit and Redirect to the list page after updating database

//MVCFunctions.HeaderRedirect("DDK_Student", "list");

}
return true;


Is not working. The entrys in the table is only the UserId and and the end it makes an entry with all the UserId that I select.
Also i have a problem with the day and the Monades(is int).
Thx for your help

K
kleanthis author 12/10/2017

Solved


if (values["UserId"])

{

var arr = MVCFunctions.explode(",", values["UserId"]);
// This is the name of the multi check box or

// list select field, its value becomes arr



var tom = values["Tomeis"];

// insert your var here
for (int i = 0; i < arr.Count(); i++)

{

var strInsert = String.Format("insert into DDK_Student (UserId, Tomeis,...fields...) values ('{0}', '{1}',....no_of_var...)", arr[i], tom,...variables... );



// add more fields from the add page to be inserted into database

CommonFunctions.db_exec(strInsert, GlobalVars.conn);

}



// Exit and Redirect to the list page after updating database

MVCFunctions.HeaderRedirect("DDK_Student", "list");

}