Hi Per,
Thanks for posting your further issue.
Based on my understanding, you still use the Repeater control to display
the data, and you add an extra checkbox column for each Repeater Item(In
your situation, every 2 rows), but when you check the CheckBox stats at
server side, you find that they are always unchecked.
===========================================
Actually, I think there are many possibilities for this issue. You need to
post some of your implement code for us to check.
Anyway, I think the likest problem may be that you did not judge the
postback, and always rebind the Repeater control in Page_Load event.
If you always rebind your repeater control to the data, then the whole
status of Repeater control will be refreshed(Initialized), so the
checkbox's checked status will be lost.
Normally, if you only bind at the first load time, then everything will
work well, like this:
Html code:
<asp:repeater id="Repeater1" runat="server">
<HeaderTemplate>
<table align="center" border="1">
</HeaderTemplate>
<ItemTemplate>
<tr>
<td align="center"><asp:CheckBox ID="cb"
Runat="server"></asp:CheckBox></td>
<td runat="server" id="job_id" align="center"><%#
DataBinder.Eval(Container.DataItem,"job_id")%></td>
<td runat="server" id="min_lvl" align="center"><%#
DataBinder.Eval(Container.DataItem,"min_lvl")%></td>
<td runat="server" id="max_lvl" align="center"><%#
DataBinder.Eval(Container.DataItem,"max_lvl")%></td>
</tr>
<tr>
<td runat="server" id="job_desc" align="center" colspan="4"><%#
DataBinder.Eval(Container.DataItem,"job_desc")%></td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:repeater>
Then, at the server side:
private void Page_Load(object sender, System.EventArgs e)
{
if(!IsPostBack)
{
SqlDataAdapter adapter=new SqlDataAdapter("select * from
jobs","server=localhost;database=pubs;uid=sa;pwd=");
DataSet ds=new DataSet();
adapter.Fill(ds);
Repeater1.DataSource=ds.Tables[0];
Repeater1.DataBind();
}
}
private void Button1_Click(object sender, System.EventArgs e)
{
foreach(RepeaterItem ri in Repeater1.Items)
{
if(ri.ItemType==ListItemType.Item||ri.ItemType==ListItemType.AlternatingItem
)
{
foreach(Control c in ri.Controls)
{
if(c is CheckBox)
{
CheckBox cb=(CheckBox)c;
if(cb.Checked)
{
this.Response.Write("The "+ ri.ItemIndex.ToString()+"th item is
checked<br>");
}
}
}
}
}
}
Note: I used Sql Server's default "jobs" table in "pubs" database.
==============================================
Please apply my suggestion above and let me know if it helps resolve your
problem.
Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.
Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! -
www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! -
www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.