【问题标题】:how to bind the value from dataset to gridview footer control?如何将数据集的值绑定到gridview页脚控件?
【发布时间】:2011-09-19 09:05:24
【问题描述】:

如何将 datase 中的数据绑定到 gridivew 页脚控件,如文本框。 我写的代码就像...

TextBox T= (TextBox)GridView.FooterRow.FindControl("txtFooter");
T.Tex= ds.Tables[0].Rows[0]["MyFirend"].ToString();

我正在获取值并将值分配给页脚文本框,但值未显示

【问题讨论】:

  • 你用什么方法执行这段代码?

标签: c# .net asp.net


【解决方案1】:

通常您在网格的 RowDataBound 事件中进行这种绑定,例如:

protected void yourNiceGridViewControl_RowDataBound(object sender, GridViewRowEventArgs e)
{
  if (e.Row.RowType == DataControlRowType.Footer)
  {
    TextBox myTextBox = e.Row.FindControl("txtFooter") as TextBox;

    if( myTextBox != null ) 
    {

      myTextBox.Tex= ds.Tables[0].Rows[0]["MyFirend"].ToString();
    }
  }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-03-27
    • 1970-01-01
    • 1970-01-01
    • 2013-03-31
    • 2014-02-09
    • 2010-10-30
    • 2011-06-25
    相关资源
    最近更新 更多