Click to See Complete Forum and Search --> : I need to get data out of a repeater. Heeelp!


Lars_V_J
June 3rd, 2003, 05:29 AM
I think I've tried everything. How do I get data out of a repeater? I have checkbox (which I *can* get), and two text columns.
Code as follows (a bit messy)

private void Button3_Click(object sender, System.EventArgs e)//Vis afkrydsede
{
bool firsttime = true;
// Datastuff data = new Datastuff();
// arr1 = (ArrayList)Repeater1.DataSource;
foreach (RepeaterItem ri in Repeater1.Items)
{
HtmlInputCheckBox cb;
HtmlInputCheckBox cb1 = (HtmlInputCheckBox)ri.FindControl("DelThisA");
HtmlInputCheckBox cb2 = (HtmlInputCheckBox)ri.FindControl("DelThisB");
if (cb1 != null)
cb = cb1;
else
cb = cb2;

if (cb != null && cb.Checked)
{
if (!firsttime)
afkrydsede.Text += ", ";
firsttime = false;
HtmlInputText t1 = (HtmlInputText)ri.FindControl("Abonnent");
HtmlInputText t2 = (HtmlInputText)ri.FindControl("f_navn");
// data = (Datastuff)arr1[ri.ItemIndex];
// afkrydsede.Text += data.abonnent + " " + data.f_navn;
afkrydsede.Text += t1.Value + " - " + t2.Value;
//((DataBoundLiteralControl)ri.Controls[2]).Text + " - " /*+
//((DataBoundLiteralControl)ri.Controls[2]).Text*/;
}
}
if (firsttime)
afkrydsede.Text = "Ingen afkrydsede";
}
}
------------
<asp:Repeater id="Repeater1" runat="server">
<HeaderTemplate>
<table border="1">
<tr>
<td><b>Valgt</b></td>
<td><b>Abonnent</b></td>
<td><b>F_navn</b></td>
</tr>
</HeaderTemplate>
<AlternatingItemTemplate>
<tr bgcolor="#0066ff">
<td>
&nbsp; <input type=checkbox id="DelThisA" value='<%# DataBinder.Eval(Container.DataItem, "ischecked") %>' runat=server NAME="IsSel">
<%# DataBinder.Eval(Container.DataItem, "IsSelected") %>
</td>
<TD>&nbsp;<%# DataBinder.Eval(Container.DataItem, "Abonnent") %></TD>
<TD>&nbsp;<%# DataBinder.Eval(Container.DataItem, "f_navn") %></TD>
</td>
</tr>
</AlternatingItemTemplate>
<ItemTemplate>
<tr bgcolor="#f0f0f0">
<td>
&nbsp; <input type=checkbox id="DelThisB" value='<%# DataBinder.Eval(Container.DataItem, "ischecked") %>' runat=server NAME="IsSel">
<%# DataBinder.Eval(Container.DataItem, "IsSelected") %>
</td>
<TD>&nbsp;<%# DataBinder.Eval(Container.DataItem, "Abonnent") %></TD>
<TD>&nbsp;<%# DataBinder.Eval(Container.DataItem, "f_navn") %></TD>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>



Thanx in advance
Lars VJ

redsolo
June 5th, 2003, 02:54 PM
hi:
i tried your sample ,it is really hard.i used a div on the form to hold the innerhtml, it is works ,but i know it is not a good solution.

you can also put a Lable on the form , use Label.Text hold your row text, but if you want to get them seperately,you must parse them .it is also hard to do , and too easy make mistakes.


i attached my project file,perhaps you can find an another solution from me. if you get it ,just tell me!