Erwin Pombett
asked on
i'm creating a checkboxlist, i need to add values, not only labels, as i need to pass a different value when the ckeckbox is checked.
Hello experts,
my problem is as follow,
i need to fill a checkboxlist with id values and labels differents,
for example Mr.DADA has an account_id = 1111, i need to see DADA as checkbox label,
but i need to pass the id value 1111.
HTML:
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------
<td valign="top">
<asp:panel id="panAccount" runat="server">
<asp:Label id="lbHeaderAccount" runat="server"> </asp:Label>
<asp:CheckBoxList id="chklAccounts_" runat="server" ></asp:CheckBoxList>
</asp:panel>
</td>
CODE BEHIND in order to populate the ckeckboxlist.
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ----------
...
User_ = new User(....);
DataTable dt = ApplicationConfiguration.S ystemConfi guration.A ccountsRep ository.Fe tchSubAcco untFromAcc ountID_ToD T(User_.Ac count_id);
foreach(DataRow myRow in dt.Rows)
{
chklAccounts_.Items.Add(my Row["lastn ame"].ToSt ring()); < --- label for the checkbox.
chklAccounts_.Items. ---- myRow["id"] ---- ; <--- how to add a value that i will recover on postback???????
}
on postback, preparing an arrayList with the id values.
-------------------------- ---------- ---------- ---------- ---------- ---------- -----
if(IsPostBack)
{
foreach(ListItem item in this.chklAccounts_.Items)
{
if(item.Selected == true)
{
alAccountsToExport.Add(... ..???....) <--- how to recover the id ??????????.
}
}
........
i need to fill the lines with question mark.
thanks in advance.
my problem is as follow,
i need to fill a checkboxlist with id values and labels differents,
for example Mr.DADA has an account_id = 1111, i need to see DADA as checkbox label,
but i need to pass the id value 1111.
HTML:
--------------------------
<td valign="top">
<asp:panel id="panAccount" runat="server">
<asp:Label id="lbHeaderAccount" runat="server"> </asp:Label>
<asp:CheckBoxList id="chklAccounts_" runat="server" ></asp:CheckBoxList>
</asp:panel>
</td>
CODE BEHIND in order to populate the ckeckboxlist.
--------------------------
...
User_ = new User(....);
DataTable dt = ApplicationConfiguration.S
foreach(DataRow myRow in dt.Rows)
{
chklAccounts_.Items.Add(my
chklAccounts_.Items. ---- myRow["id"] ---- ; <--- how to add a value that i will recover on postback???????
}
on postback, preparing an arrayList with the id values.
--------------------------
if(IsPostBack)
{
foreach(ListItem item in this.chklAccounts_.Items)
{
if(item.Selected == true)
{
alAccountsToExport.Add(...
}
}
........
i need to fill the lines with question mark.
thanks in advance.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.