jasonsalas
IS-IT--Management
Hi DataGrid gurus,
Got a query for you. Let me try and explain what's going on: I've got a DataGrid control on a page with editing and sorting enabled (paging will come later, too), and I added a custom method that allows a record to be added. To do this, I bound a series of Textbox controls in <FooterTemplate>s nested within <asp:TemplateColumn>s.
To fire the event, I:
(1) use a Button control in the <FooterTemplate> - <asp:Button
id="btnAddRecord" CommandName="Insert" Text="Add" runat="server"/>
(2) wire the OnItemCommand event of the DataGrid to the custom method -
<aspataGrid id="dgContacts" AllowSorting="True" ShowFooter="False"
OnSortCommand="SortGrid" OnItemCommand="Add_New_Record"
AutoGenerateColumns="False" OnEditCommand="Edit_Contacts"
OnUpdateCommand="Update_Contacts" OnCancelCommand="Cancel_Edit" .......>
However, I can now add record, but now the sorting and editing links don't
work, at which point they return "System.NullReferenceException: Object
reference not set to an instance of an object." Do you know what object
isn't referenced? Or is there some other argument I can pass to the
DataGrid that differentiates between the built-in sorting and editing
abilities, and my custom adding?
To debug it, I took out the OnItemCommand property in my DataGrid control (which I'm setting declaratively BTW, not in code), and sorting and editing
works like it should (except the ability to add records).
Thanks!
Jason
Got a query for you. Let me try and explain what's going on: I've got a DataGrid control on a page with editing and sorting enabled (paging will come later, too), and I added a custom method that allows a record to be added. To do this, I bound a series of Textbox controls in <FooterTemplate>s nested within <asp:TemplateColumn>s.
To fire the event, I:
(1) use a Button control in the <FooterTemplate> - <asp:Button
id="btnAddRecord" CommandName="Insert" Text="Add" runat="server"/>
(2) wire the OnItemCommand event of the DataGrid to the custom method -
<aspataGrid id="dgContacts" AllowSorting="True" ShowFooter="False"
OnSortCommand="SortGrid" OnItemCommand="Add_New_Record"
AutoGenerateColumns="False" OnEditCommand="Edit_Contacts"
OnUpdateCommand="Update_Contacts" OnCancelCommand="Cancel_Edit" .......>
However, I can now add record, but now the sorting and editing links don't
work, at which point they return "System.NullReferenceException: Object
reference not set to an instance of an object." Do you know what object
isn't referenced? Or is there some other argument I can pass to the
DataGrid that differentiates between the built-in sorting and editing
abilities, and my custom adding?
To debug it, I took out the OnItemCommand property in my DataGrid control (which I'm setting declaratively BTW, not in code), and sorting and editing
works like it should (except the ability to add records).
Thanks!
Jason