Click here to Skip to main content
15,888,454 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
I have 3 information that need to display:
1) Company Name
2) Last Run Time
3) Next Run Time

Currently, it will display like append text (ABC SDN BHDLast Run : 10/10/2013 10:50:03Next Run : 10/10/2013 10:55:03) since I want it display them without changing the size of the gridview

Here the codes for get the data.GridView1.FooterRow.Cells[0].Text ="ABC SDN BHD"+""+"Last Run : " + rd.GetValue(0).ToString()+""+"Next Run : " + rd.GetValue(1).ToString(); is the code to display in footer part but it append as 1 text eventhough I put the space between them.


HTML
private void LastRun()
    {
        try
        {
           
            string connStr = ConfigurationManager.ConnectionStrings["ConnString"].ConnectionString;
            SqlConnection con = new SqlConnection(connStr);
            
            con.Open();
            SqlDataReader rd;
            SqlCommand cmd = new SqlCommand("Select [LastRunTime],[NextRunTime] from [PRODUCTIONSYSTEM].[dbo].[PQI_TV_Batch]", con);
            rd = cmd.ExecuteReader();
            while (rd.Read())
            {
                GridView1.FooterRow.Cells[0].Font.Size = 8;
                GridView1.FooterRow.Cells[0].Font.Bold = true;
                GridView1.FooterRow.Cells[0].Text ="ABC SDN BHD"+""+"Last Run : " + rd.GetValue(0).ToString()+""+"Next Run : " + rd.GetValue(1).ToString()
            }
            con.Close();
        }
        catch (Exception ex)
        {
            Response.Write(ex.ToString());
        }
    }


Here code for Gridview footer. The code below is to merge the footer row to become 1 row from 25 rows. In this part, it will display the informations in LastRun().
HTML
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
  {

      if (e.Row.RowType == DataControlRowType.Footer)
      {
          //Response.Write(e.Row.Cells.Count);
          int m = e.Row.Cells.Count;  //return 25
          for (int i = m - 1; i >= 1; i += -1)
          {
              e.Row.Cells.RemoveAt(0);
              //e.Row.Cells.RemoveAt(3);
          }
           e.Row.Cells[0].ColumnSpan = m;
          //e.Row.Cells[0].RowSpan = m;



      }


Please help me to suggest how to create distance between the three information at footer part.

edit:
I would like to have information at footer part like this:

ABC Sdn Bhd<----space---> Last Run: 10/10/2013 <----space---> Next Run: 11/10/2013

not like this
ABC Sdn BhdLast Run: 10/10/2013Next Run: 11/10/2013
Posted
Updated 9-Oct-13 20:27pm
v4
Comments
Thanks7872 10-Oct-13 0:13am    
Do you mean some thing like Padding/Margin or Wrap text inside GridView cell?
ekmashafina 10-Oct-13 1:01am    
actually, for GridView1.FooterRow.Cells[0].Text in my code is holding 3 information.
1)"ABC SDN BHD"+ ( just a text)
2)"Last Run : " + rd.GetValue(0).ToString() ( pull out from table)
3)"Next Run : " + rd.GetValue(1).ToString(); (pull out from table)
I tried to have space between the word by put +"" + but it doesn't work.
I am not sure either padding/margin or wrap text can solve my problem since i'm newbie of asp.net.:(
Thanks7872 10-Oct-13 1:20am    
Then you have to set GridView width. Set Width="100%" in GridView. Let me know what happens.
ekmashafina 10-Oct-13 2:28am    
currently, i have the gridview.width = 100% and it not affect the footer.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900