Hello Friends,
In My Application my first ListBox is populating on selected index of Dropdown and then According to Multiple Selected Item in my First Listbox i am filling SecondList box.
The Problem is That Second Listbox always taking first item in FirstList Box even it is not selected,
to populate the first list box my code is
protected void ddlSkillType_SelectedIndexChanged(object sender, EventArgs e)
{
List<TblSkillType> lstSkillType = ServiceAccess.GetProxy().GetSkillType();
List<TblSkill> lstSkill = ServiceAccess.GetProxy().GetAllSkill();
List<TblSkillDetail> lstSkillDetails = ServiceAccess.GetProxy().GetAllSkillDtls();
var skill = (from a in lstSkillType
from b in lstSkill
from c in lstSkillDetails
where a.SkillTypeId == Convert.ToInt32(ddlSkillType.SelectedValue) && a.SkillTypeId == b.SkillTypeId && b.SkillId == c.SkillId
select new { b.SkillId, c.SkillName }).ToList();
lstboxSkill.DataSource = skill;
lstboxSkill.DataTextField = "SkillName";
lstboxSkill.DataValueField = "SkillId";
lstboxSkill.DataBind();
}
and for filling second listbib my code is
protected void imgbtnMoveRightListBox_Click(object sender, ImageClickEventArgs e)
{
for (int i = 0; i < lstboxSkill.Items.Count; i++)
{
if (lstboxSkill.Items[i].Selected)
{
lstBBoxSkill2.Items.Add(lstboxSkill.Items[i]);
}
}
}
i amchecking it using break point and i found Second ListBox Always taking fistitem of firstList box even it is not selected.
and after multiple selecting in first listbox,second listbox fills with multiple fistitem of first listbox
i don't know what is the problem.
Kindly help me to fix it.
Thanks In advance...!!
My aspx Code
<td>
<asp:DropDownList ID="ddlSkillType" runat="server" CssClass="Dropdownlist myddl" OnSelectedIndexChanged="ddlSkillType_SelectedIndexChanged" AutoPostBack="true"></asp:DropDownList>
</td>
<td>
<table class="tblListBoxContainer">
<colgroup>
<col class="col1" />
<col class="col2" />
<col class="col3" />
</colgroup>
<tr>
<td>
<asp:ListBox ID="lstboxSkill" runat="server" CssClass="ListBox" Rows="5" SelectionMode="Multiple" OnSelectedIndexChanged="lstboxSkill_SelectedIndexChanged"></asp:ListBox>
</td>
<td>
<div style="width: 25px;">
<asp:ImageButton ID="imgbtnMoveRightListBox" runat="server" ImageUrl="~/images/Common/next-blue.png" Height="10" Width="20" OnClick="imgbtnMoveRightListBox_Click" />
<br />
<br />
<asp:ImageButton ID="imgbtnMoveLeftListBox" runat="server" ImageUrl="~/images/Common/back-blue.png" Height="10" Width="20" OnClick="imgbtnMoveLeftListBox_Click" />
</div>
</td>
<td>
<asp:ListBox ID="lstBBoxSkill2" runat="server" CssClass="ListBox" Rows="5" SelectionMode="Multiple"></asp:ListBox>
</td>
<td>
<asp:Label ID="lbltxt" runat="server" CssClass="Label"></asp:Label>
</td>
</tr>
</table>
</td>