Drop down will have the following
ABC
DEF
GHI
Based on the selection i will have the data binded to the first list box from the database say for example my First list box is as follows
AB
CD
EF
Now if i select AB and click on Add Button provided it has to be added to the second list box and the database so that it should be removed and will be shown in second.
Now if i select CD my second list box will have the data as follows
AB
CD // I would like to select this item by default on clicking button as per given in the code so that only CD should be inserted
What i need is here to set the selected value to the next item
Here is my code
protected void Add_Click(object sender, ImageClickEventArgs e)
{
AdminPaytypes.SelectionMode = System.Web.UI.WebControls.ListSelectionMode.Multiple;
CustomerPaytypes.SelectionMode = System.Web.UI.WebControls.ListSelectionMode.Multiple;
if (AdminPaytypes.SelectedIndex >= 0)
{
for (int i = 0; i < AdminPaytypes.Items.Count; i++)
{
if (AdminPaytypes.Items[i].Selected)
{
if (!array.Contains(AdminPaytypes.Items[i]))
{
array.Add(AdminPaytypes.Items[i]);
}
}
}
for (int i = 0; i < array.Count; i++)
{
if (!CustomerPaytypes.Items.Contains(((ListItem)array[i])))
{
CustomerPaytypes.Items.Add(((ListItem)array[i]));
// AT this place i have to set the selected value to the array item i am getting
}
AdminPaytypes.Items.Remove(((ListItem)array[i]));
}
}
// This J loop also running twice but i have to insert only one item
for (int j = 0; j < CustomerPaytypes.Items.Count; j++)
{
mlocal_strStoredProcName = "uspInsertCustomerPaytypes";
oSysAdminGrantPaytypes.FedTaxID = ddlEmployer.SelectedValue;
oSysAdminGrantPaytypes.PayFrequencyTypeID = CustomerPaytypes.SelectedItem.ToString();
oSysAdminGrantPaytypes.PayFrequencyDesc = CustomerPaytypes.SelectedValue;
oSysAdminGrantPaytypes.Insert(mlocal_strStoredProcName);
//CustomerPaytypes.Items.Clear();
}
}

Suthish NairPosted Mar 24, 2011, 12:35 AM
Dorababu MekaPosted Mar 24, 2011, 12:11 AM
Suthish NairPosted Mar 24, 2011, 12:10 AM