This is my ListView
<asp:ListView ID="ListView1" runat="server" >
<LayoutTemplate>
<table runat="server" id="itemTable">
<tr>
<th>th>
<th>Name 1th>
<th>Name 2th>
<th>Name 3th>
<th>Name 4th>
<th>Name 5th>
tr>
<tr runat="server" id="itemPlaceholder" >tr>
table>
LayoutTemplate>
<ItemTemplate>
<tr>
<td><asp:CheckBox ID="CheckBox1" runat="server" />td>
<td><%# DataBinder.Eval(Container.DataItem, "name1") %>td>
<td><%# DataBinder.Eval(Container.DataItem, "name2") %>td>
<td><%# DataBinder.Eval(Container.DataItem, "name3") %>td>
<td><%# DataBinder.Eval(Container.DataItem, "name4") %>td>
<td><%# DataBinder.Eval(Container.DataItem, "name5") %>td>
tr>
ItemTemplate>
asp:ListView>
This is My code
protected void Button1_Click(object sender, EventArgs e)
{
for (int i = 0; i < ListView1.Items.Count; i++)
{
CheckBox chk = ListView1.Items[i].FindControl("CheckBox1") as CheckBox;
if(chk.Checked == true)
{
** Here I want to be able to get the value of
<td><%# DataBinder.Eval(Container.DataItem, "name1") %>td>
From my ListView ItemTemplate**
}
}
}
Loading
Roei BarPosted Aug 3, 2009, 7:44 AM
you will have a CheckedItems Property in this, and the Value is the text in it, and if you want complex Object with multiple properties, you can have an object, and on the build just do an Override on the ToString for the displayed item Text and once you run all all Checked Items, you will have the ItemId, and by ItemId you can get any property in the ListView