Link to home
Start Free TrialLog in
Avatar of Erwin Pombett
Erwin PombettFlag for Switzerland

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.SystemConfiguration.AccountsRepository.FetchSubAccountFromAccountID_ToDT(User_.Account_id);
                  
                  foreach(DataRow myRow in dt.Rows)
                  {
                        chklAccounts_.Items.Add(myRow["lastname"].ToString());    < --- 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.
ASKER CERTIFIED SOLUTION
Avatar of Munawar Hussain
Munawar Hussain
Flag of Pakistan image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial