Dynamically show/hide gridview footer?

G

gnewsgroup

Well, I am trying to use the footer row of a GridView for insertion
purpose. There are some articles about this, for example, the
gridviewguy.com has an example, which always displays the footer row.

I would like to display the footer row, only when a LinkButton "Add
New" is clicked. And after the new record is saved to the database,
let the footer row disappear.

In the LinkButton's click event handler, I simply say:

protected myLinkButton_Click(object s, EventArgs e)
{
myGridView.ShowFooter = true;
}

I would attempt to make the footer disappear in the GridView's
rowcommand handler, but let's forget about this for now.

It seems to work, but somehow, the "Add New" button has to be clicked
twice for the footer to show up. This is the first problem. Note that
I am not using Ajax.

Another problem is that the footer refuses to show up no matter how
hard I click on myLinkButton if I place this GridView in a View
control of a MultiView. The GridView itself isn't dynamically
created, although I *do* dynmically set the ShowFooter property of the
GridView.

Right now, I also let the GridView always display the footer, but only
show/hide the controls inside the footer. (I have template field in
the footer). This works fine, but there is a blank footer row at the
bottom. I think it's sorta nicer to only display the footer row when
"Add New" is clicked.

Not sure if I made the situation clear. If yes, anyone has an idea
why ?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top