I am trying to find a Label inside a Repeater, I am using:
protected void lnkbtnEditRecord_Click(object sender, EventArgs e)
{
salesEditPanel.Visible = true;
resultPanel.Visible = false;
zipPanel.Visible = false;
ddlPanel.Visible = false;
topPanel.Visible = false;
Label lblSalesId = (Label)(Repeater2.Items[0].FindControl("lblSalesID"));
DataView dv = FillSalesPersonForm(Convert.ToInt32(lblSalesId.Text));
frmViewSalesPeople.DataSource = dv;
frmViewSalesPeople.DataBind();
}
This works great if the repeater only has one result, but if it has more then one it only gets the id for the first item listed. Any ideas on how to fix this?
EDIT: Basically the return is filled with user info and with each user info is a link to another page. So when I click the link I want to get the ID from the label for the record the link was clicked for. So If I click record 4 out of 5 I want and the ID for record 4 is 900 I want to get the 900 to pass.
Thanks!
Try something like this:
foreach (RepeaterItem item in rptItems.Items)
{
if (item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem)
{
var lbl= (Label)item.FindControl("lblMyLabel");
lbl.Text = "do something to your label";
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With