GridView with ObjectDataSource Show Footer on Empty Data

5th Dementian

New Member
There is no \[code\]ShowFooterWhenEmpty\[/code\] property in GridView ;(When I didn't use ObjectDataSource for data binding it was as simple as:\[code\]... SqlDataAdapter adapter = new SqlDataAdapter(cmd); DataTable data = http://stackoverflow.com/questions/15861001/new DataTable(); conn.Open(); adapter.Fill(data); conn.Close(); if (data.Rows.Count > 0) { grid.DataSource = data; grid.DataBind(); } else { data.Rows.Add(data.NewRow()); grid.DataSource = data; grid.DataBind(); int TotalColumns = grid.Rows[0].Cells.Count; grid.Rows[0].Cells.Clear(); grid.Rows[0].Cells.Add(new TableCell()); grid.Rows[0].Cells[0].ColumnSpan = TotalColumns; grid.Rows[0].Cells[0].Text ="No Records Found"; }...\[/code\]called by \[code\]Page_Load() if (!IsPostBack) {...}\[/code\]Now \[code\]ObjectDataSource\[/code\] stands for auto-binding and paging.How am I supposed to render the Footer where my Insert button located?Tried \[code\]OnSelected\[/code\] event of \[code\]ObjectDataSource\[/code\] but I don't know how add a row in there.\[code\]protected void ODS_Selected(object sender, ObjectDataSourceStatusEventArgs e){ DataSet ds = e.ReturnValue as DataSet; // Add empty row here or 'No Records Found' string to force Footer show}\[/code\]Help, please!
 
Back
Top