<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" PageSize="20">
<Columns>
<asp:TemplateField HeaderText="开始日期" SortExpression="ksrq">
<ItemTemplate>
<asp:Label ID="Label4" runat="server" Text='<%# Bind("ksrq","yyyy-MM-dd") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>请问我在后台代码中如何得到Label4的值或改变它的值。
好像不能直接用Label4.Text = "XXX"
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
//Label lb = (Label)e.Row.FindControl("Label4");
Label lb = (Label)GridView1.FooterRow.FindControl("Label4");
lb.Text = "aaa";
}这要写总是不行,提示错误:“未将对象引用设置到对象的实例。”
<Columns>
<asp:TemplateField HeaderText="开始日期" SortExpression="ksrq">
<ItemTemplate>
<asp:Label ID="Label4" runat="server" Text='<%# Bind("ksrq","yyyy-MM-dd") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>请问我在后台代码中如何得到Label4的值或改变它的值。
好像不能直接用Label4.Text = "XXX"
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
//Label lb = (Label)e.Row.FindControl("Label4");
Label lb = (Label)GridView1.FooterRow.FindControl("Label4");
lb.Text = "aaa";
}这要写总是不行,提示错误:“未将对象引用设置到对象的实例。”
解决方案 »
- 求一思路 关于。net 多表 高效率的 站内搜索
- 为什么总是会出现"远程主机强迫关闭了一个现有的连接"
- jquery 获取c#的返回值,long的值为什么会四舍五入
- (高分求救)Ajax中使用Div的问题
- 怎样用sqlserver2005的企业管理器远程连接其他数据库!谢谢
- coolite 会出现 requset failure 的错误提示??
- DropDownList绑定一个表数据太多,怎末解决?解决就揭帖~~~
- 存储过程问题,感觉有点难
- 2个巨菜的问题,60分
- 关于服务器重新启动后session里面的数据的监测!
- 想问下大家在哪里下载的电子书啊?(顺便散分)
- 请教高手!自定义复合元件问题 (Custom Control Collection)
{
if (e.Row.RowType == DataControlRowType.Footer)
{
Label lb = (Label)GridView1.FooterRow.FindControl("Label4");
lb.Text = "aaa";
}
}