CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2001
    Location
    Denmark
    Posts
    453

    I need to get data out of a repeater. Heeelp!

    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)
    Code:
    		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

  2. #2
    Join Date
    Apr 2003
    Location
    China
    Posts
    48

    it is really hard get data from repeater!!

    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!
    Attached Files Attached Files
    try, and try..

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured