I have a dropwdown where I select a name from the dropdown list. This populates a grid view with that record. Once I select that record it will populate a form with textboxes of info for that record. There is a delete button in that form and when I click the delete button I want it to refresh the grid with that record removed from the grid. so it shows a blank grid or the grid minus that record. Does anyone know how to do this. Is this something handled in the code behind? Here is my code for the delete button on the design page:

<asp:button id="deleteButton" CommandName="Delete"    
                    style="background-image:url('Images/Button.gif'); text-align:center;background-color:Transparent; cursor:hand; background-repeat:no-repeat; background-position:left; padding-left:15px;"    
                    Runat="server" Height="25px" BorderStyle=None  ForeColor=White   Text="Delete"    
                    Width="99px" CssClass="style3" onclientclick="return confirm('Are you surely want to delete this record?');"  />

and I have used a databind to the grid on the page load and delete button event and neither has worked.

You need to rebind the gridview after deletion of record.

You need to rebind the gridview after deletion of record.

How is that done? Is that done in the code behind. Can that be done on the datasource?

>How is that done? Is that done in the code behind. Can that be done on the datasource?

Yes, you have to handle "RowDeleted" or "RowDeleting" event (it depends upon how you configure gridview) and write,

GridView1.DataBind();
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.