Surya sasidhar
Surya sasidhar

Reputation: 30313

how to bind the value from dataset to gridview footer control?

how to bind the data from datase to gridivew footer control like text box. i write the code like...

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

I am getting value an assign the value to footer textbox but value is not showing

Upvotes: 0

Views: 3624

Answers (1)

Davide Piras
Davide Piras

Reputation: 44605

usually you do this kind of binding in the RowDataBound event of your grid, for example:

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();
    }
  }
}

Upvotes: 1

Related Questions