I am having trouble wrapping my head around the viewstate usage. Let's say I have a dataset I need to keep between various postbacks, why would this not work?
Assuming a gridview set up as such:
When I click the delete button, I want to put the dataset in the viewstate. What I find happens when I step through with the debugger is that the page load event fires before the rowdeleting event of the gridview. It is in the row deleting event I manipulate the dataset and store it in the viewstate. However, this obviously doesn't work as by the time the load event fires, my dataset is set to nothing. How should I be handling this?HTML Code:<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CellPadding="4" ForeColor="#333333" GridLines="None" Style="z-index: 100; left: 103px; position: absolute; top: 67px"> <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /> <Columns> <asp:BoundField DataField="ClientName" HeaderText="ClientName" SortExpression="ClientName" /> <asp:BoundField DataField="ClientRate" HeaderText="ClientRate" SortExpression="ClientRate" /> <asp:BoundField DataField="ClientHours" HeaderText="ClientHours" SortExpression="ClientHours" /> <asp:TemplateField HeaderText="Type"> <ItemTemplate> <asp:Button ID="but" Text="Delete Row" CommandName = "Delete" runat ="server"/> <asp:DropDownList ID="DropDownList1" runat="server"> </asp:DropDownList> </ItemTemplate> </asp:TemplateField> </Columns> <RowStyle BackColor="#F7F6F3" ForeColor="#333333" /> <EditRowStyle BackColor="#999999" /> <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" /> <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" /> <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /> <AlternatingRowStyle BackColor="White" ForeColor="#284775" /> </asp:GridView>




Reply With Quote