Hi Indresh,
I am not able to configure the C# due to lots of my trial and errors. Please review it, It doesnt carry the additional fields yet
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
using System.Collections.Specialized;
using System.Text;
public partial class Default : System.Web.UI.Page
{
private string GetConnectionString()
{
//Where DBConnection is the connetion string that was set up in the web config file
return System.Configuration.ConfigurationManager.ConnectionStrings["DBConnection"].ConnectionString;
}
protected void Button1_Click(object sender, EventArgs e)
{
string strEmployeeName = string.Empty;
foreach (ListItem item in ListBox1.Items)
{
if (item.Selected)
{
strEmployeeName += item.Text + ",";
}
}
InsertRecords(strEmployeeName.Remove(strEmployeeName.Length - 1));
}
private void InsertRecords(string employeeName)
{
SqlConnection conn = new SqlConnection(GetConnectionString());
SqlCommand cmd = new SqlCommand("INSERT INTO Table1 (Employees) Values(@EmployeeName)", conn);
cmd.CommandType = CommandType.Text; cmd.Parameters.AddWithValue("@EmployeeName", employeeName);
conn.Open(); cmd.ExecuteNonQuery();
conn.Close();
Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "Script", "alert('Records Successfuly Saved!');", true);
}
}