我可以在GridView标题模板中动态更改Label的文本吗?

时间:2011-12-07 07:10:07

标签: c#

我能够找到控件并更新文本。但是,更新的值不会在页面上呈现。这是我在RowDataBound事件中使用的代码。

 if (e.Row.RowType == DataControlRowType.Header)
 {
      for (int i = 0; i < 52; i++)
      {
           Label lblWeekDate = e.Row.FindControl(lblName + i) as Label;

           if (lblWeekDate != null)
           {
                lblWeekDate = e.Row.FindControl(lblName + i) as Label;
                lblWeekDate.Text = burstStartWeek.Day.ToString();

                if (lblWeekDate.Text.Length == 1)
                     lblWeekDate.Text = "00" + lblWeekDate.Text;

                burstStartWeek = burstStartWeek.AddDays(7);
           }
      }
 }

1 个答案:

答案 0 :(得分:0)

将模式更改为:

Content="{Binding Mode=TwoWay}"

可能有帮助...

在xaml上找到你想要更新的控件并设置那个绑定属性....默认情况下可能是TwoWay但是值得尝试一下