Gridview 新手问题 急啊 有空就来看下 谢谢各位
public void getAllContent()
{
LuckHomeService.Applications[] app = luckHome.GetApplicationType();
DataTable table = luckHome.GetLuckHomeContent(app[0].CodeName.ToString(), "yinchengliang", UserType.ADGroup.ToString(), DateTime.Now.AddDays(-30), DateTime.Now);
for (int i = 0; i < table.Rows.Count; i++)
{
Label lblWho = (Label)GridView1.Rows[i].FindControl("lblMessageWho");
Label lblDo = (Label)GridView1.Rows[i].FindControl("lblMessageDo");
Label lblWhat = (Label)GridView1.Rows[i].FindControl("lblMessageWhat");
Label lblTime = (Label)GridView1.Rows[i].FindControl("lblMessageTime");
Label lblBody = (Label)GridView1.Rows[i].FindControl("lblMessageBody");
lblWho.Text = table.Rows[i]["Sponsor"].ToString();
lblDo.Text = table.Rows[i]["ShortName"].ToString();
lblWhat.Text = table.Rows[i]["Title"].ToString();
lblTime.Text = table.Rows[i]["ActionTime"].ToString();
lblBody.Text = table.Rows[i]["Description"].ToString();
}
}
界面就是
我的GRIDVIEW 里 有 那5个LABEL
-------------
问题就是
GridView1.Rows[i].FindControl("lblMessageWho");
这句时候就报错 意思就是 girdview 没有ROW[1]
以前做过 但是现在确实想不来了 希望各位帮下~
项目进行ing..