In SharePoint Server 2013 I have a 4 list
- Common List
- HR list
- Finance list
- IT List
How can I achieve this solution please Modify this code Empstrength textbox I type above 50 and I select a HR list the data will store in commonlist and HR list.
protected void Button1_Click(object sender, EventArgs e) {
using (SPSite site = new SPSite(SPContext.Current.Web.Url))
{
using (SPWeb web = site.OpenWeb())
{
SPList list = web.Lists["CommonList"];
SPListItem listItem = list.Items.Add();
listItem["Department"] = Department.Text;
listItem["EmpStrength"] = EmpStrength.Text;
listItem["Description"] = Description.Text;
listItem["DueDate"] = DueDate.Text;
//UniqueId = int.Parse(listItem["ConnectID"].ToString());
// listItem["ConnectID"] = UniqueId + 1;
listItem["Status"] = Status.Text;
web.AllowUnsafeUpdates = true;
listItem.Update();
//Guid id = listItem.UniqueId;
}
}
if ( 50 <= int.Parse(EmpStrength.Text))
{
Department.SelectedItem.Text = "HRList";
SPSite site = new SPSite(SPContext.Current.Web.Url);
SPWeb web = site.OpenWeb();
SPList lis = web.Lists["HRList"];
SPListItem lisItem = lis.Items.Add();
lisItem["EmpStrength"] = EmpStrength.Text;
lisItem["Status"] = Status.Text;
web.AllowUnsafeUpdates = true;
lisItem.Update();
}
else if (50 <= int.Parse(EmpStrength.Text))
{
Department.SelectedItem.Text = "ITList";
SPSite site = new SPSite(SPContext.Current.Web.Url);
SPWeb web = site.OpenWeb();
SPList lis = web.Lists["ITList"];
SPListItem liss = lis.Items.Add();
liss["EmpStrength"] = EmpStrength.Text;
liss["Status"] = Status.Text;
web.AllowUnsafeUpdates = true;
liss.Update();
}
else
{
Department.SelectedItem.Text = "FinanceList";
SPSite site = new SPSite(SPContext.Current.Web.Url);
SPWeb web = site.OpenWeb();
SPList lis = web.Lists["FinanceList"];
SPListItem liss = lis.Items.Add();
liss["EmpStrength"] = EmpStrength.Text;
liss["Status"] = Status.Text;
web.AllowUnsafeUpdates = true;
liss.Update();
}
}
}
}
Department.SelectedItem.Text = "ITList";
Department.SelectedItem.Text = "HRList";
Department.SelectedItem.Text = "FinanceList";
is it correct..?
Dropdown selection not working here I entered above 50 it will store in Common list and HRlist. In dropdown I selected ITList or Finance List it will stored in only HRList and Commonlist. Please anyone modify this code.