1
我创建了位于Repeater Control中的LinkButton。 CategoryID是LinkButton控件中的一个变量,必须在Repeater控件绑定到数据后获取值。但是CategoryID始终为零。为什么链接按钮控制变量没有得到任何值?
我有以下的ASP和C#代码:背后
<asp:Repeater ID="rpt1" runat="server"
OnItemDataBound="rpt1_ItemDataBound"
OnItemCommand="rpt1_ItemCommand">
<ItemTemplate>
<div>
<%# Eval("Name") %>-<%# Eval("CollectionType")%>
<asp:LinkButton ID="LinkButton1" runat="server" Text="[edit item]"
PostBackUrl='AddItem.aspx?CategoryID=<%# Eval("CollectionID")%>' />
</div>
</ItemTemplate>
</asp:Repeater>
代码:
public void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
List<GlassesCollection> gc = BL.GetDataBL.GetCollection();
rpt1.DataSource = gc;
rpt1.DataBind();
}
}
任何想法,为什么类别ID变量没有得到任何价值,我怎样才能解决这个问题?
做了'GlassesCollection'对象有一个'CollectionID'属性定义?它总是设置? – Oded 2012-01-28 23:05:45
你可以看到(并在此输入)html页面上呈现什么? – Aristos 2012-01-29 00:09:28
Oded,在GlassesCollection对象中定义的CollectionID属性。 – Michael 2012-01-29 00:25:07