如何提取datalist中的label控件的值
我的代码如下:
private void DataList_ItemCommand(object source, System.Web.UI.WebControls.DataListCommandEventArgs e)
{
string id=((Label)e.Item.FindControl("goodsid")).Text;
if(e.CommandName=="state0")
{
Response.Redirect("test.aspx?ID="+id);
}
if(e.CommandName=="state1")
{
Response.Redirect("test.aspx?ID="+id);
}
if(e.CommandName=="image")
{
Response.Redirect("test.aspx?ID="+id);
}
}
goodsid是datalist里的一个Label控件,我用上面的代码取出的值总是空的,实际上它是绑定了值的啊,怎么才能取出来啊!