我无法在 asp.net 中获取项目 ID、值或文本
I cant get item id, value or text in asp.net
我无法获取项目 ID、值或文本。我怎样才能得到这个项目?我是 asp.net 的新手,找不到对此的明确支持。代码 returns 为空。这是我的代码:
<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate>
<asp:Label ID="lblID" runat="server" Visible="false" Text="çidden mal O_O"></asp:Label>
</ItemTemplate>
</asp:Repeater>
<div class="col-md-12">
<asp:Button ID="ekle" runat="server" class="btn btn-danger pull-right" Text="Gönder" OnClick="ekle_Click" />
</div>
protected void ekle_Click(object sender, EventArgs e)
{
for (int i = 0; i < Repeater1.Items.Count; i++)
{
Label strNewsID = (Label)Repeater1.Items[i].FindControl("lblID");
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('" + strNewsID.ToString() + "')", true);
}
}
感谢您的帮助!
protected void ekle_Click(object sender, EventArgs e)
{
foreach (RepeaterItem item in Repeater1.Items)
{
Label strNewsID = (Label)item.FindControl("lblID");
if(strNewsID!=null)
{
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('" + strNewsID.Text +"')",true);
}
}
}
我无法获取项目 ID、值或文本。我怎样才能得到这个项目?我是 asp.net 的新手,找不到对此的明确支持。代码 returns 为空。这是我的代码:
<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate>
<asp:Label ID="lblID" runat="server" Visible="false" Text="çidden mal O_O"></asp:Label>
</ItemTemplate>
</asp:Repeater>
<div class="col-md-12">
<asp:Button ID="ekle" runat="server" class="btn btn-danger pull-right" Text="Gönder" OnClick="ekle_Click" />
</div>
protected void ekle_Click(object sender, EventArgs e)
{
for (int i = 0; i < Repeater1.Items.Count; i++)
{
Label strNewsID = (Label)Repeater1.Items[i].FindControl("lblID");
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('" + strNewsID.ToString() + "')", true);
}
}
感谢您的帮助!
protected void ekle_Click(object sender, EventArgs e)
{
foreach (RepeaterItem item in Repeater1.Items)
{
Label strNewsID = (Label)item.FindControl("lblID");
if(strNewsID!=null)
{
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('" + strNewsID.Text +"')",true);
}
}
}