Search code examples
c#asp.netobout

obout grid using automated update/insert/delete statement


I am having issues using the Obout grid control in a webform.

I created a SqlDataSource that has a "where" clause using a label control's text property on the page. This label's text property is updated with radiobuttons. The SqlDataSource has automated insert, delete and update statements. Everything works fine until I databind when a radiobutton is selected.

I doubt posting any code will help, however here is the aspx page.

<cc1:Grid ID="grdIntelligence" runat="server" AllowPaging="False" AllowRecordSelection="False" AutoGenerateColumns="False" DataSourceID="SqlGetIntelligence" NumberOfPagesShownInFooter="-1" ShowFooter="False">
                    <AddEditDeleteSettings AddLinksPosition="Top" NewRecordPosition="Top" />
                    <Columns>
                        <cc1:Column AllowEdit="true" AllowDelete="true" HeaderText="EDIT" Width="125" runat="server" />
                        <cc1:Column  Visible ="false" DataField="ID" HeaderText="ID" Index="0" SortExpression="ID">
                        </cc1:Column>
                        <cc1:Column DataField="Name" HeaderText="Name" Index="1" SortExpression="Name">
                        </cc1:Column>
                        <cc1:Column  DataField="MRTypeID" HeaderText="MRTypeID" Index="0" SortExpression="MRTypeID">
                        </cc1:Column>
                    </Columns>

                    <ScrollingSettings ScrollHeight="300px" ScrollWidth="600px" />
                </cc1:Grid>
                <asp:SqlDataSource ID="SqlGetIntelligence" runat="server" ConnectionString="<%$ ConnectionStrings:sqlConnectionString_rw %>" DeleteCommand="DELETE FROM [tblMarketResearch] WHERE [ID] = @ID" InsertCommand="INSERT INTO [tblMarketResearch] ([Name], [MRTypeID]) VALUES (@Name, @SelectedMarketIntelligence)" SelectCommand="SELECT * FROM [tblMarketResearch] WHERE ([MRTypeID] = @MRTypeID) ORDER BY [Name]" UpdateCommand="UPDATE [tblMarketResearch] SET [Name] = @Name, [MRTypeID] = @MRTypeID WHERE [ID] = @ID" OnInserting="SqlGetIntelligence_Inserting">
                    <DeleteParameters>
                        <asp:Parameter Name="ID" Type="Int32" />
                    </DeleteParameters>
                    <InsertParameters>
                        <asp:Parameter Name="Name" Type="String" />
                        <asp:Parameter Name="SelectedMarketIntelligence" Type="Int32" />
                    </InsertParameters>
                    <SelectParameters>
                        <asp:ControlParameter ControlID="lblSelectedIntelligenceType" DefaultValue="2" Name="MRTypeID" PropertyName="Text" Type="Int32" />
                    </SelectParameters>
                    <UpdateParameters>
                        <asp:Parameter Name="Name" Type="String" />
                        <asp:Parameter Name="MRTypeID" Type="Int32" />
                        <asp:Parameter Name="ID" Type="Int32" />
                    </UpdateParameters>
                </asp:SqlDataSource>

Here is where I databind it in the code behind's radiobutton change event

private void updateGrids()
{
    grdIntelligence.DataSource = SqlGetIntelligence;            
    grdIntelligence.DataBind();
}

Solution

  • I found the answer, I had to set the viewstatemode property of the grid to disabled and it worked after that. Hope this helps someone.