使用自动更新/插入/删除语句的obout网格

时间:2015-03-23 22:01:06

标签: c# asp.net obout

我在webform中使用Obout网格控件时遇到问题。

我创建了一个SqlDataSource,其中包含"其中"子句在页面上使用标签控件的文本属性。此标签的文本属性使用单选按钮进行更新。 SqlDataSource具有自动插入,删除和更新语句。一切正常,直到我选择了无线电按钮时数据绑定。

我怀疑发布任何代码都会有所帮助,但这里是aspx页面。

<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>

这里是我在后面的代码放射性按钮更改事件中数据绑定的地方

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

1 个答案:

答案 0 :(得分:0)

我找到了答案,我必须将网格的viewstatemode属性设置为禁用,然后它才能工作。希望这有助于某人。