读取 DataList 绑定的数据问题! 各位请帮忙.
两张数据表 TABLE1 和 TABLE2 两个页面 ASP1.aspx 和 ASP2.aspx
ASP1.aspx页面的GridView绑定表 TABLE1,通过TABLE1表的ID子段传递到 ASP2.aspx页面的DataList控件,并用DataList显示相关数据.
我想把 DataList 里面的ID字段的值赋值给本页面的一个LABEL1控件, 请问如何获得DataList里面的ID子段的值.在线等!!!!
------解决方案--------------------设置Datalist的datakeyname为要绑定表的主键,
int ID = Convert.ToInt32(DataList1.DataKeys[e.itemIndex].Value.ToString());
------解决方案--------------------在ItemDataBound事件中
------解决方案--------------------错了,
Label lb = e.item.FindControl( "ControlID ") as Label
------解决方案--------------------怎么可能呢?
protected void ToolList_ItemDataBound(object sender, DataListItemEventArgs e)
{
Label lblName1 = e.Item.FindControl( "labName1 ") as Label;
Label lblName2 = e.Item.FindControl( "labName2 ") as Label;
Label lblName3 = e.Item.FindControl( "labName3 ") as Label;
string CurrentCulture = CultureInfo.CurrentCulture.Name;
switch (CurrentCulture.ToLower())
{
case "zh-cn ":
lblName1.Visible = false;
lblName3.Visible = false;
break;
case "zh-tw ":
lblName1.Visible = false;
lblName2.Visible = false;
break;
default:
lblName2.Visible = false;
lblName3.Visible = false;
break;
}
}