How to Validate Two listboxes
I have two Listbox and have same items in both listbox but i want to save items in one listbox not be saved in databsae from another listbox
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Sanjeeb LenkaPosted Oct 4, 2013, 5:21 AM
you can use like this
for (int i = 0; i < listtrainee.Items.Count; i++)
{
if (Listtrainne_ab.Items.Contains(listtrainee.Items[i]))
{
lblMsg.Text = "Present and Absent Employee Should Not Be Matched";
}
}
Khargesh RajputPosted Oct 4, 2013, 4:33 AM
thanks
Khargesh RajputPosted Oct 4, 2013, 3:34 AM
int i, j;
for (i = 0; i <= listtrainee.Items.Count - 1; i++)
{
for (j = 0; j <= Listtrainne_ab.Items.Count - 1; j++)
{
//foreach (ListItem lst1 in listtrainee.Items)
//{
// foreach (ListItem lst2 in Listtrainne_ab.Items)
// {
if (listtrainee.Items[i].Value == Listtrainne_ab.Items[j].Value)
// if (empoyee.Split(',')[0].ToString() == empoyee_ab.Split(',')[0].ToString())
{
lblMsg.Text = "Present and Absent Employee Should Not Be Matched";
// ClientScript.RegisterStartupScript(Page.GetType(), "", "");
}
else
{
int execount = objdal.ExecuteNonQuery(CommandType.Text, strQuery, hsInput);
if (execount > 0)
{
}}}}
but there is saved data at each loop
Khargesh RajputPosted Oct 4, 2013, 3:20 AM
on btclick listbox1 and listbox2 items not to be same
Sanjeeb LenkaPosted Oct 4, 2013, 3:06 AM
i didn't get your point. plz provide more details.