本文介绍了如何在gridview中编辑行值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友们,

我收到错误消息,如"DataSource和DataSourceID都在" grdbasetype"上定义.删除一个定义."

可以解决我的问题吗?

我的代码在下面...

Hi friends,

I am getting an error as in "Both DataSource and DataSourceID are defined on ''grdbasetype''. Remove one definition. "

Can ayone solve my problem?

My code is below...

<asp:GridView ID="grdbasetype" runat="server" AutoGenerateColumns="False" Style="width: 100%"

                                                CellPadding="4" ForeColor="#333333" GridLines="None" BorderColor="MidnightBlue"

                                                BorderStyle="Solid" BorderWidth="2px" Font-Names="Verdana" Font-Size="Small"

                                                AllowPaging="true" PageSize="10" OnPageIndexChanging="grdbasetype_PageIndexChanging"

                                                DataKeyNames="basetype" DataSourceID="SqlDataSource1">
                                                <Columns>
                                                    <asp:TemplateField HeaderText="Select">
                                                        <ItemTemplate>
                                                            <asp:CheckBox ID="chkCheck" runat="server" AutoPostBack="true" CausesValidation="False"

                                                                ToolTip='<%# ((GridViewRow)Container).RowIndex + 1%>' />
                                                        </ItemTemplate>
                                                    </asp:TemplateField>
                                                    <asp:ButtonField HeaderText="Edit" Text="Edit" />
                                                    <asp:ButtonField HeaderText="Delete" Text="Delete" />
                                                    <%--<asp:ButtonField CommandName="Edit" HeaderText="Edit" Text="Edit" />
                                                    <asp:ButtonField CommandName="Update" HeaderText="Update" Text="Update" />
                                                    <asp:ButtonField CommandName="Insert" HeaderText="Insert" Text="Insert" />
                                                    <asp:BoundField DataField="modelname" HeaderText="Model Name" SortExpression="modelname" />
                                                    <asp:BoundField DataField="basetype" HeaderText="Base Type" SortExpression="basetype" />
                                                    <asp:BoundField DataField="description" HeaderText="Description" SortExpression="description" />
                                                    <asp:BoundField DataField="rs" HeaderText="Rupees" SortExpression="rs" />
                                                    <asp:BoundField DataField="euro" HeaderText="Euro" SortExpression="euro" />
                                                    <asp:BoundField DataField="dollar" HeaderText="Dollar" SortExpression="dollar" />
                                                    <asp:BoundField DataField="modelid" HeaderText="Model Id" SortExpression="modelid" />--%>
                                                    <asp:TemplateField HeaderText="Model Name">
                                                        <EditItemTemplate>
                                                            <asp:Label ID="lblModelname" runat="server" Style="text-align: left" Text='<%# Eval("modelname") %>'></asp:Label>
                                                        </EditItemTemplate>
                                                        <ItemTemplate>
                                                            <asp:Label ID="lblModelname" runat="server" Style="text-align: left" Text='<%# Bind("modelname") %>'></asp:Label>
                                                        </ItemTemplate>
                                                    </asp:TemplateField>
                                                    <asp:TemplateField HeaderText="Base Type ">
                                                        <ItemTemplate>
                                                            <asp:Label ID="lblbasetype" runat="server" Style="text-align: left" Text='<%# Eval("basetype") %>'></asp:Label>
                                                        </ItemTemplate>
                                                    </asp:TemplateField>
                                                    <asp:TemplateField HeaderText="Description">
                                                        <ItemTemplate>
                                                            <asp:Label ID="lblDescription" runat="server" Style="text-align: left" Text='<%# Eval("description") %>'></asp:Label>
                                                        </ItemTemplate>
                                                    </asp:TemplateField>
                                                    <asp:TemplateField HeaderText="Rupees">
                                                        <ItemTemplate>
                                                            <asp:Label ID="lblRupees" runat="server" Style="text-align: left" Text='<%# Eval("rs") %>'></asp:Label>
                                                        </ItemTemplate>
                                                    </asp:TemplateField>
                                                    <asp:TemplateField HeaderText="Euro">
                                                        <ItemTemplate>
                                                            <asp:Label ID="lblEuro" runat="server" Style="text-align: left" Text='<%# Eval("euro") %>'></asp:Label>
                                                        </ItemTemplate>
                                                    </asp:TemplateField>
                                                    <asp:TemplateField HeaderText="Dollar">
                                                        <ItemTemplate>
                                                            <asp:Label ID="lblDollar" runat="server" Style="text-align: left" Text='<%# Eval("dollar") %>'></asp:Label>
                                                        </ItemTemplate>
                                                    </asp:TemplateField>
                                                </Columns>
                                                <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                                                <RowStyle BackColor="#EFF3FB" />
                                                <EditRowStyle BackColor="#2461BF" />
                                                <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
                                                <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
                                                <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                                                <AlternatingRowStyle BackColor="White" />
                                            </asp:GridView>
                                            <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:OrionConnectionString %>"

                                                DeleteCommand="DELETE FROM [mbasetype] WHERE [basetype] = @basetype"

                                                UpdateCommand="UPDATE [mbasetype] SET [modelname] = @modelname, [description] = @description ,[rs]=@rs, [euro]=@euro, [dollar]=@dollar WHERE [basetype] = @basetype">
                                                <DeleteParameters>
                                                    <asp:Parameter Name="basetype" Type="String" />
                                                </DeleteParameters>
                                                <UpdateParameters>
                                                    <asp:Parameter Name="modelname" Type="String" />
                                                    <asp:Parameter Name="basetype" Type="String" />
                                                    <asp:Parameter Name="description" Type="String" />
                                                    <asp:Parameter Name="rs" Type="Double" />
                                                    <asp:Parameter Name="dollar" Type="Double" />
                                                    <asp:Parameter Name="euro" Type="Double" />
                                                    <asp:Parameter Name="modelid" Type="String" />
                                                </UpdateParameters>
                                            </asp:SqlDataSource>



Thanking in advance..
Swapnil



Thanking in advance..
Swapnil

推荐答案



Thanking in advance..
Swapnil



Thanking in advance..
Swapnil


Swapnil 2009 wrote:
Swapnil 2009 wrote:

I am getting an error as in "Both DataSource and DataSourceID are defined on ''grdbasetype''. Remove one definition. "

I am getting an error as in "Both DataSource and DataSourceID are defined on ''grdbasetype''. Remove one definition. "



Error message itself is self explanatory.Use either DataSource or DataSourceID.



Error message itself is self explanatory.Use either DataSource or DataSourceID.



这篇关于如何在gridview中编辑行值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 21:57