I am using a webdatagrid to display information from a SQL Server Database. I have a template column with a 'Delete' button in it, which allows the user to delete a record.
My webdatagrid markup is as follows:
<ig:webdatagrid id="wdgSamples" runat="server" AutoGenerateColumns="False" StyleSetName="Default" width="475px" DataKeyFields="Recnum" EnableViewState="true" EnableDataViewState="true" > <Columns> <ig:BoundDataField DataFieldName="SampleDate" Key="SampleDate" Width="90px" > <Header Text="Sample Date" /> </ig:BoundDataField> <ig:BoundDataField DataFieldName="AAS" Key="AAS" Width="135px" > <Header Text="Average Aphid Score" /> </ig:BoundDataField> <ig:BoundDataField DataFieldName="Sprayed" Key="Sprayed" Width="60px" > <Header Text="Sprayed" /> </ig:BoundDataField> <ig:BoundDataField DataFieldName="OpenBolls" Key="OpenBolls" Width="55px" > <Header Text="OpenBolls" /> </ig:BoundDataField> <ig:BoundDataField DataFieldName="Recnum" Key="Recnum" Hidden="true"> <Header Text="Sample Id" /> </ig:BoundDataField> <ig:BoundDataField DataFieldName="CropId" Key="CropId" Hidden="true"> <Header Text="Crop Id" /> </ig:BoundDataField> <ig:TemplateDataField Key="colDelete" width="55px" > <ItemTemplate> <asp:ImageButton ID="btnDelete" runat="server" ImageUrl="~/Images/btnDelete.gif" OnCommand="btnDelete_Select" CommandName="Select" CommandArgument='<%# Eval("Recnum") %>' /> </ItemTemplate> </ig:TemplateDataField> </Columns> <Behaviors> <ig:Paging PagerAppearance="Bottom" PageSize="8" Enabled="true" /> <ig:Selection CellClickAction="Row" RowSelectType="Single"> <SelectionClientEvents RowSelectionChanged="wdgSamples_rowSelChanged" /> </ig:Selection> <ig:Sorting ></ig:Sorting> </Behaviors></ig:webdatagrid>
I have a section at the bottom of the page that allows the user to enter information to be able to add a record to the grid. For some reason, when the user saves an additional record and the page does a postback, I am getting the following error:
DataBinding: 'Infragistics.Web.UI.GridControls.GridRecordItem' does not contain a property with the name 'Recnum'
The code highlights the line with the 'OnCommand="btnDelete_Select" CommandName="Select" CommandArgument='<% for the template button.
I have no idea why this is happening, can anyone help me with this? This error does not happen everytime, but does occur regularly!!!
Hello lorettac242,
After the row is added how do you bind the grid? Please check this out:http://forums.infragistics.com/forums/p/50842/267272.aspx#267272
Is Recnum primary key?