User1216627406 posted
Back for more...
Hopefully, this is simple.
I have the following GridView loop:
foreach (GridViewRow row in Gridview1.Rows)
{
string registerNumber = (row.FindControl("txtNum") as TextBox).Text;
if (row.RowIndex == 0)
{
this.SetInitialRow2(registerNumber);
}
else
{
AddNewRow2(registerNumber);
}
foreach (RepeaterItem Item in Repeater2.Items)
{
(Item.FindControl("BtnAdd2") as Button).Visible = Repeater2.Items.Count > 1;
(Item.FindControl("btnDelete") as Button).Visible = Repeater2.Items.Count > 1;
}
}
This works good.
However, I am trying to use same logic but in Repeater but I am stuck on this this line:
if (Items == 0
...
How do I write the following line in Rpeater?
if (row.RowIndex == 0)
Here is the entire code:
foreach (RepeaterItem Items in Repeater1.Items)
{
string registerNumber = (Items.FindControl("txtNum") as TextBox).Text;
if (Items == 0)
{
this.SetInitialRow2(registerNumber);
}
else
{
AddNewRow2(registerNumber);
}
foreach (RepeaterItem Item in Repeater2.Items)
{
(Item.FindControl("BtnAdd2") as Button).Visible = Repeater2.Items.Count > 1;
(Item.FindControl("btnDelete") as Button).Visible = Repeater2.Items.Count > 1;
}
}
I have tried this:
if (registerNumber == "0")
No errors but it is not producing any results. It was working in GridView.
I solved it.
if (Items.ItemIndex == 0)
As always, thank you