views:

430

answers:

2

work on C# asp.net vs05.i need to save some value and show them on the gridview.So under the button event i write a code that save value ,and show on gridview.I can save value but problem occur when show on gridview.So i use the DataSource .I also set the GridviewTask-->Choose Data Source--> DataSourceID ,because user need to edit information set on the page. after use the DataSourceID show this error message : Both DataSource and DataSourceID are defined on 'GridView2'. Remove one definition.

How can i use the both in one grid view?if i can not? then how to give user this facility that they can edit information set on the grid with out use any other contorl.

A: 

You cannot - either use DataSource or DataSourceID - but you can't use both at the same time.

From your question, it's not quite clear why you'd want to use both at the same time. What is it exactly that you're trying to accomplish?? Please clarify.

Marc

marc_s
A: 

There are different type of parameter support by ObjectDatasource like

<asp:ObjectDataSource ID="odsCityDetails" runat="server" InsertMethod="AddCity" SelectMethod="GetCityByCityID"
                        TypeName="abc.BLL.City" UpdateMethod="ModifyCity">
                        <UpdateParameters>
                            <asp:Parameter Name="CityID" Type="Int32" />
                            <asp:Parameter Name="CityName" Type="String" />
                            <asp:Parameter Name="stateID" Type="Int32" />
                        </UpdateParameters>
                        <SelectParameters>
                            <asp:ControlParameter ControlID="grdCity" Name="cityID" PropertyName="SelectedValue"
                                Type="Int32" />
                        </SelectParameters>
                        <InsertParameters>
                            <asp:Parameter Name="CityName" Type="String" />
                            <asp:Parameter Name="stateID" Type="Int32" />
                        </InsertParameters>
                    </asp:ObjectDataSource>

So use objectdatasource only

Because objectdatasource support insertion,updating and selection

Muhammad Akhtar