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..
{
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..
解决方案 »
- 读取Excel数据??
- xml问题,初学者
- DataGridView导航条控件添加查询记录功能 ,用它可以实现多表查询吗? 或者这导航只支持单表查询?
- 【如何用C#删除系统保护文件夹中内容】+【菜鸟求教】
- 求 C# 获得另外一程序 句柄 后控制该程序,如控制其透明,或窗体大小等(求代码)
- 关于字符串比较的问题
- 1000分求VS2005控件安装示例
- HttpContext的使用中遇到保护级别限制的问题
- 求救!ASP.NET(c#)中数据库记录条件显示问题
- 高分向C# + Datawindow.net高手求救
- 要考试了,有道题目老师也拿不准答案!
- 如何在后台生成一个System.Windows.Forms.RichTextBox,并且显示在一个Border里?
要用gridview1.findcontrol("") ?
要获取GridView的lable,GridView必须先有行数才可以,你可以先绑定个table让GridView先有行数在进行操作,不过用上面的就好了
我忘了
gridview.datasourse=table;
gridview.databind();
if(GridView1.Rows.count > 0)
{
// 你要执行的代码
}