mugsey
asked on
get datakey item from checkbox in listview control
I populate listview with checkbox that is populated from database like this........
<asp:ListView ID="List" runat="server" DataKeyNames="Id">
<LayoutTemplate>
<asp:PlaceHolder ID="itemPlaceholder" runat="server"></asp:Place Holder>
</LayoutTemplate>
<ItemTemplate>
<asp:CheckBox ID="ListCheckBoxField" runat="server" Text='<%#Eval("Description ") %>' />
</ItemTemplate>
</asp:ListView>
.......
for (int i = 0; i < List.Items.Count; i++)
{
var item = List.Items[i];
var checkbox = item.FindControl("checkbox Control") as CheckBox;
if (checkbox != null && checkbox.Checked)
{
//NEED TO GET THE DATAKEY VALUE FOR THE TEXTBOX
}
}
...
I need to get each datakey value of the checkbox
<asp:ListView ID="List" runat="server" DataKeyNames="Id">
<LayoutTemplate>
<asp:PlaceHolder ID="itemPlaceholder" runat="server"></asp:Place
</LayoutTemplate>
<ItemTemplate>
<asp:CheckBox ID="ListCheckBoxField" runat="server" Text='<%#Eval("Description
</ItemTemplate>
</asp:ListView>
.......
for (int i = 0; i < List.Items.Count; i++)
{
var item = List.Items[i];
var checkbox = item.FindControl("checkbox
if (checkbox != null && checkbox.Checked)
{
//NEED TO GET THE DATAKEY VALUE FOR THE TEXTBOX
}
}
...
I need to get each datakey value of the checkbox
ASKER
Whoops sorry I mean checkbox!!!!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks but it is not updating is it inserting into table
So the listview control containing one checkbox is populated from database. The database table has ID, Description so this is how checkboxes are populated.
If a checkbox is checked I want to get the underlying Primary Key of the checkbox as it is populated from the database.
var item = List.Items[i];
var checkbox = item.FindControl("checkbox Control") as CheckBox;
if (checkbox != null && checkbox.Checked)
{
}
So the listview control containing one checkbox is populated from database. The database table has ID, Description so this is how checkboxes are populated.
If a checkbox is checked I want to get the underlying Primary Key of the checkbox as it is populated from the database.
var item = List.Items[i];
var checkbox = item.FindControl("checkbox
if (checkbox != null && checkbox.Checked)
{
}
what text box you are talking about