早前发布过repeater控件的使用,因为用repeater较少,或是仅用简单操作,对它使用相当不熟练,这次利用它很方便的解决了一个问题,而且是使用linq读取数据就记录一下。
绑定问题后面显示答案个数,不是拼语句,不太好做,平时对repeater又不熟,想到用itemDateBind
下面是绑定repeater
跟多事件功能参看 http://www.cnblogs.com/VirtualMJ/archive/2007/03/09/669613.html
绑定问题后面显示答案个数,不是拼语句,不太好做,平时对repeater又不熟,想到用itemDateBind
protected void repMore_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
{
int qId = Convert.ToInt32(DataBinder.Eval(e.Item.DataItem, "Question_ID"));//得到主键
int aNum = Answer.GetAnswerNumByQId(qId);
((Label)e.Item.FindControl("lblANum")).Text = aNum.ToString();
}
}
{
if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
{
int qId = Convert.ToInt32(DataBinder.Eval(e.Item.DataItem, "Question_ID"));//得到主键
int aNum = Answer.GetAnswerNumByQId(qId);
((Label)e.Item.FindControl("lblANum")).Text = aNum.ToString();
}
}
Code
下面是绑定repeater
using QsqLib.LinqSql;
using QsqLib;
using QsqLib.Manyou.QA;
using QsqLib.Manyou;
using System.Collections.Generic;
using System.Text;
using System.Linq.Dynamic;
Codeusing QsqLib;
using QsqLib.Manyou.QA;
using QsqLib.Manyou;
using System.Collections.Generic;
using System.Text;
using System.Linq.Dynamic;