Forums: [SOLVED] multiple selection - Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

[SOLVED] multiple selection Rate Topic: -----

#1 User is offline   kleanthis 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 55
  • Joined: 23-April 09

Posted 08 December 2017 - 11:09 AM

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

#2 User is offline   timnorvel 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 234
  • Joined: 21-September 07

Posted 08 December 2017 - 01:42 PM

Is this what you mean:

https://xlinesoft.co...iple_values.htm


If not, please provide more details about what you're trying to do.

Thanks,
Tim
0

#3 User is offline   kleanthis 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 55
  • Joined: 23-April 09

Posted 08 December 2017 - 05:49 PM

Dear Tim
this is the screen shot from my add page

Posted Image


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
0

#4 User is offline   kleanthis 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 55
  • Joined: 23-April 09

Posted 10 December 2017 - 03:20 PM

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");
}



0

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic