asp.net datagrid postback all rows
I am facing a little problem here....I need a datagrid control, which is maintained at client side (user will edit the grid at the client side in an overlay control with no interaction with the server, I will use javascript to add/edit rows here)....so when user hits the save button (it will be an ajax call) on the form I want the whole data in this grid (the grid will have less than开发者_如何学Python 50 rows) to get submit to the server. I am using a grid from the component art tool which only sends back the rows which were added or edited. I don't want this. So, I am thinking to use the asp.net gridview. I am not sure if asp.net gridview does this or not. Does any body know about this or a better way to achieve what I am trying to do???
A GridView
would work, as it uses ViewState
to maintain its information. During the postback you can access all records, including changed and unchanged values.
There would be multiple ways to solve the AJAX requirements when editing the grid. The simplest solution would be to wrap the grid in an UpdatePanel
and hook into the GridView event of choice, such as GridView.RowUpdated, GridView.RowDeleted, etc. All of the actions handled by the server via an asynchronous postback will be seamless to the user with no ugly flicker, etc.
Sample markup:
<asp:UpdatePanel UpdateMode="Conditional">
<ContentTemplate>
<asp:GridView ID="MyGridView" runat="server" OnRowUpdated="MyGridView_RowUpdated" .. />
</ContentTemplate>
</asp:UpdatePanel>
Code behind:
protected void MyGridView_RowUpdated(object sender, GridViewUpdatedEventArgs e)
{
//do what you need with the affected row, etc.
}
With the above you would still need to determine how to store the data, and bind, etc. based on your requirements...
精彩评论