Newbie, gridview problem ASP.net 2005

Discussion in 'ASP .Net' started by verci, Aug 19, 2006.

  1. verci

    verci Guest

    Hi
    Can anyone help me I'm running Win XP Pro SP2, VS2005 Team, .Net Framework
    2.0 and SQL Server2005, I can't delete records using the gridviews
    deletecommand, the updatecommand works fine, edit and calcel all works fine
    the problem is the delete part, I get the message:

    -----------------------------------------------ERROR
    MESSAGE----------------------------------------------------------------------------------------
    Must declare the scalar variable "@productid".
    Description: An unhandled exception occurred during the execution of the
    current web request. Please review the stack trace for more information
    about the error and where it originated in the code.

    Exception Details: System.Data.SqlClient.SqlException: Must declare the
    scalar variable "@productid".
    -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


    Here's my default3.aspx source code so far I've been stuck two days, thanks
    and best regards. :(

    <%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default3.aspx.vb"
    Inherits="Default3" %>
    !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" >

    <head runat="server">

    <title>Untitled Page</title>

    </head>

    <body>

    <form id="form1" runat="server">

    <div>

    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$
    ConnectionStrings:NwindConnectionString %>"

    SelectCommand="SELECT p.ProductID, p.ProductName, p.CategoryID,
    c.CategoryName FROM Products p inner join Categories c on p.CategoryID =
    c.CategoryID"

    UpdateCommand="Update Products Set ProductID=@ProductID,
    ProductName=@ProductName, CategoryID=@CategoryID where ProductID=@ProductID"

    DeleteCommand="delete from products where productid=@productid">

    </asp:SqlDataSource>

    <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$
    ConnectionStrings:NwindConnectionString %>"

    SelectCommand="SELECT [CategoryID], [CategoryName] FROM [Categories]">

    </asp:SqlDataSource>

    </div>

    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
    DataSourceID="SqlDataSource1" CellPadding="4" ForeColor="#333333"
    GridLines="None" AllowPaging="True">

    <Columns>

    <asp:CommandField ButtonType="Image" CancelImageUrl="~/Images/Cancel.gif"
    EditImageUrl="~/Images/WRITE2.gif"

    ShowEditButton="True" UpdateImageUrl="~/Images/Update.gif"
    DeleteImageUrl="~/Images/waste-trash.gif" ShowDeleteButton="True" />

    <asp:TemplateField SortExpression="ProductID">

    <EditItemTemplate>

    <asp:Label ID="TextBox1" runat="server" Text='<%# Bind("ProductID")%>'
    Visible=false></asp:Label>

    </EditItemTemplate>

    <ItemTemplate>

    <asp:Label ID="Label2" runat="server" Text='<%# Bind("ProductID") %>'
    Visible=false></asp:Label>

    </ItemTemplate>

    </asp:TemplateField>

    <asp:BoundField DataField="ProductName" HeaderText="ProductName"
    SortExpression="ProductName" />

    <asp:TemplateField HeaderText="CategoryID" SortExpression="CategoryID">

    <EditItemTemplate>

    <asp:DropDownList ID="DropDownList1" runat="server"
    DataSourceID="SqlDataSource2"

    DataTextField="CategoryName" DataValueField="CategoryID" SelectedValue='<%#
    Bind("CategoryID") %>' >

    </asp:DropDownList>

    </EditItemTemplate>

    <ItemTemplate>

    <asp:Label ID="Label1" runat="server" Text='<%# Bind("CategoryName")
    %>'></asp:Label>

    </ItemTemplate>

    </asp:TemplateField>

    </Columns>

    <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />

    <SelectedRowStyle BackColor="#D1DDF1" ForeColor="#333333" Font-Bold="True"
    />

    <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center"
    />

    <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />

    <AlternatingRowStyle BackColor="White" />

    <RowStyle BackColor="#EFF3FB" />

    <EditRowStyle BackColor="#2461BF" />

    </asp:GridView>

    </form>

    </body>

    </html>
    verci, Aug 19, 2006
    #1
    1. Advertising

  2. you have missed a lot of commands

    <asp:GridView ... DataKeyNames="ProductID" ...

    and add the DeleteParameters, UpdateParameters and InsertParameters (if you
    want to insert) in the DataSource




    --

    Bruno Alexandre
    "a Portuguese in Københav, Danmark"



    "verci" <> escreveu na mensagem
    news:%...
    > Hi
    > Can anyone help me I'm running Win XP Pro SP2, VS2005 Team, .Net Framework
    > 2.0 and SQL Server2005, I can't delete records using the gridviews
    > deletecommand, the updatecommand works fine, edit and calcel all works
    > fine the problem is the delete part, I get the message:
    >
    > -----------------------------------------------ERROR
    > MESSAGE----------------------------------------------------------------------------------------
    > Must declare the scalar variable "@productid".
    > Description: An unhandled exception occurred during the execution of the
    > current web request. Please review the stack trace for more information
    > about the error and where it originated in the code.
    >
    > Exception Details: System.Data.SqlClient.SqlException: Must declare the
    > scalar variable "@productid".
    > -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    >
    >
    > Here's my default3.aspx source code so far I've been stuck two days,
    > thanks and best regards. :(
    >
    > <%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default3.aspx.vb"
    > Inherits="Default3" %>
    > !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    > <html xmlns="http://www.w3.org/1999/xhtml" >
    >
    > <head runat="server">
    >
    > <title>Untitled Page</title>
    >
    > </head>
    >
    > <body>
    >
    > <form id="form1" runat="server">
    >
    > <div>
    >
    > <asp:SqlDataSource ID="SqlDataSource1" runat="server"
    > ConnectionString="<%$ ConnectionStrings:NwindConnectionString %>"
    >
    > SelectCommand="SELECT p.ProductID, p.ProductName, p.CategoryID,
    > c.CategoryName FROM Products p inner join Categories c on p.CategoryID =
    > c.CategoryID"
    >
    > UpdateCommand="Update Products Set ProductID=@ProductID,
    > ProductName=@ProductName, CategoryID=@CategoryID where
    > ProductID=@ProductID"
    >
    > DeleteCommand="delete from products where productid=@productid">
    >
    > </asp:SqlDataSource>
    >
    > <asp:SqlDataSource ID="SqlDataSource2" runat="server"
    > ConnectionString="<%$ ConnectionStrings:NwindConnectionString %>"
    >
    > SelectCommand="SELECT [CategoryID], [CategoryName] FROM [Categories]">
    >
    > </asp:SqlDataSource>
    >
    > </div>
    >
    > <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
    > DataSourceID="SqlDataSource1" CellPadding="4" ForeColor="#333333"
    > GridLines="None" AllowPaging="True">
    >
    > <Columns>
    >
    > <asp:CommandField ButtonType="Image" CancelImageUrl="~/Images/Cancel.gif"
    > EditImageUrl="~/Images/WRITE2.gif"
    >
    > ShowEditButton="True" UpdateImageUrl="~/Images/Update.gif"
    > DeleteImageUrl="~/Images/waste-trash.gif" ShowDeleteButton="True" />
    >
    > <asp:TemplateField SortExpression="ProductID">
    >
    > <EditItemTemplate>
    >
    > <asp:Label ID="TextBox1" runat="server" Text='<%# Bind("ProductID")%>'
    > Visible=false></asp:Label>
    >
    > </EditItemTemplate>
    >
    > <ItemTemplate>
    >
    > <asp:Label ID="Label2" runat="server" Text='<%# Bind("ProductID") %>'
    > Visible=false></asp:Label>
    >
    > </ItemTemplate>
    >
    > </asp:TemplateField>
    >
    > <asp:BoundField DataField="ProductName" HeaderText="ProductName"
    > SortExpression="ProductName" />
    >
    > <asp:TemplateField HeaderText="CategoryID" SortExpression="CategoryID">
    >
    > <EditItemTemplate>
    >
    > <asp:DropDownList ID="DropDownList1" runat="server"
    > DataSourceID="SqlDataSource2"
    >
    > DataTextField="CategoryName" DataValueField="CategoryID"
    > SelectedValue='<%# Bind("CategoryID") %>' >
    >
    > </asp:DropDownList>
    >
    > </EditItemTemplate>
    >
    > <ItemTemplate>
    >
    > <asp:Label ID="Label1" runat="server" Text='<%# Bind("CategoryName")
    > %>'></asp:Label>
    >
    > </ItemTemplate>
    >
    > </asp:TemplateField>
    >
    > </Columns>
    >
    > <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
    >
    > <SelectedRowStyle BackColor="#D1DDF1" ForeColor="#333333" Font-Bold="True"
    > />
    >
    > <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center"
    > />
    >
    > <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
    >
    > <AlternatingRowStyle BackColor="White" />
    >
    > <RowStyle BackColor="#EFF3FB" />
    >
    > <EditRowStyle BackColor="#2461BF" />
    >
    > </asp:GridView>
    >
    > </form>
    >
    > </body>
    >
    > </html>
    >
    >
    Bruno Alexandre, Aug 19, 2006
    #2
    1. Advertising

  3. --

    Bruno Alexandre
    "a Portuguese in Københav, Danmark"



    "verci" <> escreveu na mensagem
    news:%...
    > Hi
    > Can anyone help me I'm running Win XP Pro SP2, VS2005 Team, .Net Framework
    > 2.0 and SQL Server2005, I can't delete records using the gridviews
    > deletecommand, the updatecommand works fine, edit and calcel all works
    > fine the problem is the delete part, I get the message:
    >
    > -----------------------------------------------ERROR
    > MESSAGE----------------------------------------------------------------------------------------
    > Must declare the scalar variable "@productid".
    > Description: An unhandled exception occurred during the execution of the
    > current web request. Please review the stack trace for more information
    > about the error and where it originated in the code.
    >
    > Exception Details: System.Data.SqlClient.SqlException: Must declare the
    > scalar variable "@productid".
    > -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    >
    >
    > Here's my default3.aspx source code so far I've been stuck two days,
    > thanks and best regards. :(
    >
    > <%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default3.aspx.vb"
    > Inherits="Default3" %>
    > !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    > <html xmlns="http://www.w3.org/1999/xhtml" >
    >
    > <head runat="server">
    >
    > <title>Untitled Page</title>
    >
    > </head>
    >
    > <body>
    >
    > <form id="form1" runat="server">
    >
    > <div>
    >
    > <asp:SqlDataSource ID="SqlDataSource1" runat="server"
    > ConnectionString="<%$ ConnectionStrings:NwindConnectionString %>"
    >
    > SelectCommand="SELECT p.ProductID, p.ProductName, p.CategoryID,
    > c.CategoryName FROM Products p inner join Categories c on p.CategoryID =
    > c.CategoryID"
    >
    > UpdateCommand="Update Products Set ProductID=@ProductID,
    > ProductName=@ProductName, CategoryID=@CategoryID where
    > ProductID=@ProductID"
    >
    > DeleteCommand="delete from products where productid=@productid">
    >
    > </asp:SqlDataSource>
    >
    > <asp:SqlDataSource ID="SqlDataSource2" runat="server"
    > ConnectionString="<%$ ConnectionStrings:NwindConnectionString %>"
    >
    > SelectCommand="SELECT [CategoryID], [CategoryName] FROM [Categories]">
    >
    > </asp:SqlDataSource>
    >
    > </div>
    >
    > <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
    > DataSourceID="SqlDataSource1" CellPadding="4" ForeColor="#333333"
    > GridLines="None" AllowPaging="True">
    >
    > <Columns>
    >
    > <asp:CommandField ButtonType="Image" CancelImageUrl="~/Images/Cancel.gif"
    > EditImageUrl="~/Images/WRITE2.gif"
    >
    > ShowEditButton="True" UpdateImageUrl="~/Images/Update.gif"
    > DeleteImageUrl="~/Images/waste-trash.gif" ShowDeleteButton="True" />
    >
    > <asp:TemplateField SortExpression="ProductID">
    >
    > <EditItemTemplate>
    >
    > <asp:Label ID="TextBox1" runat="server" Text='<%# Bind("ProductID")%>'
    > Visible=false></asp:Label>
    >
    > </EditItemTemplate>
    >
    > <ItemTemplate>
    >
    > <asp:Label ID="Label2" runat="server" Text='<%# Bind("ProductID") %>'
    > Visible=false></asp:Label>
    >
    > </ItemTemplate>
    >
    > </asp:TemplateField>
    >
    > <asp:BoundField DataField="ProductName" HeaderText="ProductName"
    > SortExpression="ProductName" />
    >
    > <asp:TemplateField HeaderText="CategoryID" SortExpression="CategoryID">
    >
    > <EditItemTemplate>
    >
    > <asp:DropDownList ID="DropDownList1" runat="server"
    > DataSourceID="SqlDataSource2"
    >
    > DataTextField="CategoryName" DataValueField="CategoryID"
    > SelectedValue='<%# Bind("CategoryID") %>' >
    >
    > </asp:DropDownList>
    >
    > </EditItemTemplate>
    >
    > <ItemTemplate>
    >
    > <asp:Label ID="Label1" runat="server" Text='<%# Bind("CategoryName")
    > %>'></asp:Label>
    >
    > </ItemTemplate>
    >
    > </asp:TemplateField>
    >
    > </Columns>
    >
    > <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
    >
    > <SelectedRowStyle BackColor="#D1DDF1" ForeColor="#333333" Font-Bold="True"
    > />
    >
    > <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center"
    > />
    >
    > <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
    >
    > <AlternatingRowStyle BackColor="White" />
    >
    > <RowStyle BackColor="#EFF3FB" />
    >
    > <EditRowStyle BackColor="#2461BF" />
    >
    > </asp:GridView>
    >
    > </form>
    >
    > </body>
    >
    > </html>
    >
    >
    Bruno Alexandre, Aug 19, 2006
    #3
  4. You are missing a lot of commands to perform such task

    first you need to especify the DataKeyNames in the GridView itself and them
    add the DeleteParameters and UpdateParameters on the DataSource

    <asp:GridView DataKeyNames="productID" ...

    <DeleteParameters>
    <asp:parameter Name="productID" Type="Decimal" />
    </DeleteParameters>

    <UpdateParameters>
    <asp:parameter Name="productID" Type="Decimal" />
    <asp:parameter Name="ProductName" Type="Decimal" />
    <asp:parameter Name="CategoryID" Type="Decimal" />
    </UpdateParameters>

    I dont know if your columns are Decimal or not, but change it to the proper
    data type

    --

    Bruno Alexandre
    "a Portuguese in Københav, Danmark"



    "verci" <> escreveu na mensagem
    news:%...
    > Hi
    > Can anyone help me I'm running Win XP Pro SP2, VS2005 Team, .Net Framework
    > 2.0 and SQL Server2005, I can't delete records using the gridviews
    > deletecommand, the updatecommand works fine, edit and calcel all works
    > fine the problem is the delete part, I get the message:
    >
    > -----------------------------------------------ERROR
    > MESSAGE----------------------------------------------------------------------------------------
    > Must declare the scalar variable "@productid".
    > Description: An unhandled exception occurred during the execution of the
    > current web request. Please review the stack trace for more information
    > about the error and where it originated in the code.
    >
    > Exception Details: System.Data.SqlClient.SqlException: Must declare the
    > scalar variable "@productid".
    > -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    >
    >
    > Here's my default3.aspx source code so far I've been stuck two days,
    > thanks and best regards. :(
    >
    > <%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default3.aspx.vb"
    > Inherits="Default3" %>
    > !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    > <html xmlns="http://www.w3.org/1999/xhtml" >
    >
    > <head runat="server">
    >
    > <title>Untitled Page</title>
    >
    > </head>
    >
    > <body>
    >
    > <form id="form1" runat="server">
    >
    > <div>
    >
    > <asp:SqlDataSource ID="SqlDataSource1" runat="server"
    > ConnectionString="<%$ ConnectionStrings:NwindConnectionString %>"
    >
    > SelectCommand="SELECT p.ProductID, p.ProductName, p.CategoryID,
    > c.CategoryName FROM Products p inner join Categories c on p.CategoryID =
    > c.CategoryID"
    >
    > UpdateCommand="Update Products Set ProductID=@ProductID,
    > ProductName=@ProductName, CategoryID=@CategoryID where
    > ProductID=@ProductID"
    >
    > DeleteCommand="delete from products where productid=@productid">
    >
    > </asp:SqlDataSource>
    >
    > <asp:SqlDataSource ID="SqlDataSource2" runat="server"
    > ConnectionString="<%$ ConnectionStrings:NwindConnectionString %>"
    >
    > SelectCommand="SELECT [CategoryID], [CategoryName] FROM [Categories]">
    >
    > </asp:SqlDataSource>
    >
    > </div>
    >
    > <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
    > DataSourceID="SqlDataSource1" CellPadding="4" ForeColor="#333333"
    > GridLines="None" AllowPaging="True">
    >
    > <Columns>
    >
    > <asp:CommandField ButtonType="Image" CancelImageUrl="~/Images/Cancel.gif"
    > EditImageUrl="~/Images/WRITE2.gif"
    >
    > ShowEditButton="True" UpdateImageUrl="~/Images/Update.gif"
    > DeleteImageUrl="~/Images/waste-trash.gif" ShowDeleteButton="True" />
    >
    > <asp:TemplateField SortExpression="ProductID">
    >
    > <EditItemTemplate>
    >
    > <asp:Label ID="TextBox1" runat="server" Text='<%# Bind("ProductID")%>'
    > Visible=false></asp:Label>
    >
    > </EditItemTemplate>
    >
    > <ItemTemplate>
    >
    > <asp:Label ID="Label2" runat="server" Text='<%# Bind("ProductID") %>'
    > Visible=false></asp:Label>
    >
    > </ItemTemplate>
    >
    > </asp:TemplateField>
    >
    > <asp:BoundField DataField="ProductName" HeaderText="ProductName"
    > SortExpression="ProductName" />
    >
    > <asp:TemplateField HeaderText="CategoryID" SortExpression="CategoryID">
    >
    > <EditItemTemplate>
    >
    > <asp:DropDownList ID="DropDownList1" runat="server"
    > DataSourceID="SqlDataSource2"
    >
    > DataTextField="CategoryName" DataValueField="CategoryID"
    > SelectedValue='<%# Bind("CategoryID") %>' >
    >
    > </asp:DropDownList>
    >
    > </EditItemTemplate>
    >
    > <ItemTemplate>
    >
    > <asp:Label ID="Label1" runat="server" Text='<%# Bind("CategoryName")
    > %>'></asp:Label>
    >
    > </ItemTemplate>
    >
    > </asp:TemplateField>
    >
    > </Columns>
    >
    > <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
    >
    > <SelectedRowStyle BackColor="#D1DDF1" ForeColor="#333333" Font-Bold="True"
    > />
    >
    > <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center"
    > />
    >
    > <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
    >
    > <AlternatingRowStyle BackColor="White" />
    >
    > <RowStyle BackColor="#EFF3FB" />
    >
    > <EditRowStyle BackColor="#2461BF" />
    >
    > </asp:GridView>
    >
    > </form>
    >
    > </body>
    >
    > </html>
    >
    >
    Bruno Alexandre, Aug 19, 2006
    #4
  5. verci

    verci Guest

    Hey many thanks Bruno!!, that did it. :)


    "Bruno Alexandre" <> wrote in message
    news:...
    > You are missing a lot of commands to perform such task
    >
    > first you need to especify the DataKeyNames in the GridView itself and
    > them add the DeleteParameters and UpdateParameters on the DataSource
    >
    > <asp:GridView DataKeyNames="productID" ...
    >
    > <DeleteParameters>
    > <asp:parameter Name="productID" Type="Decimal" />
    > </DeleteParameters>
    >
    > <UpdateParameters>
    > <asp:parameter Name="productID" Type="Decimal" />
    > <asp:parameter Name="ProductName" Type="Decimal" />
    > <asp:parameter Name="CategoryID" Type="Decimal" />
    > </UpdateParameters>
    >
    > I dont know if your columns are Decimal or not, but change it to the
    > proper data type
    >
    > --
    >
    > Bruno Alexandre
    > "a Portuguese in Københav, Danmark"
    >
    >
    >
    > "verci" <> escreveu na mensagem
    > news:%...
    >> Hi
    >> Can anyone help me I'm running Win XP Pro SP2, VS2005 Team, .Net
    >> Framework 2.0 and SQL Server2005, I can't delete records using the
    >> gridviews deletecommand, the updatecommand works fine, edit and calcel
    >> all works fine the problem is the delete part, I get the message:
    >>
    >> -----------------------------------------------ERROR
    >> MESSAGE----------------------------------------------------------------------------------------
    >> Must declare the scalar variable "@productid".
    >> Description: An unhandled exception occurred during the execution of the
    >> current web request. Please review the stack trace for more information
    >> about the error and where it originated in the code.
    >>
    >> Exception Details: System.Data.SqlClient.SqlException: Must declare the
    >> scalar variable "@productid".
    >> -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    >>
    >>
    >> Here's my default3.aspx source code so far I've been stuck two days,
    >> thanks and best regards. :(
    >>
    >> <%@ Page Language="VB" AutoEventWireup="false"
    >> CodeFile="Default3.aspx.vb" Inherits="Default3" %>
    >> !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    >> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    >> <html xmlns="http://www.w3.org/1999/xhtml" >
    >>
    >> <head runat="server">
    >>
    >> <title>Untitled Page</title>
    >>
    >> </head>
    >>
    >> <body>
    >>
    >> <form id="form1" runat="server">
    >>
    >> <div>
    >>
    >> <asp:SqlDataSource ID="SqlDataSource1" runat="server"
    >> ConnectionString="<%$ ConnectionStrings:NwindConnectionString %>"
    >>
    >> SelectCommand="SELECT p.ProductID, p.ProductName, p.CategoryID,
    >> c.CategoryName FROM Products p inner join Categories c on p.CategoryID =
    >> c.CategoryID"
    >>
    >> UpdateCommand="Update Products Set ProductID=@ProductID,
    >> ProductName=@ProductName, CategoryID=@CategoryID where
    >> ProductID=@ProductID"
    >>
    >> DeleteCommand="delete from products where productid=@productid">
    >>
    >> </asp:SqlDataSource>
    >>
    >> <asp:SqlDataSource ID="SqlDataSource2" runat="server"
    >> ConnectionString="<%$ ConnectionStrings:NwindConnectionString %>"
    >>
    >> SelectCommand="SELECT [CategoryID], [CategoryName] FROM [Categories]">
    >>
    >> </asp:SqlDataSource>
    >>
    >> </div>
    >>
    >> <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
    >> DataSourceID="SqlDataSource1" CellPadding="4" ForeColor="#333333"
    >> GridLines="None" AllowPaging="True">
    >>
    >> <Columns>
    >>
    >> <asp:CommandField ButtonType="Image" CancelImageUrl="~/Images/Cancel.gif"
    >> EditImageUrl="~/Images/WRITE2.gif"
    >>
    >> ShowEditButton="True" UpdateImageUrl="~/Images/Update.gif"
    >> DeleteImageUrl="~/Images/waste-trash.gif" ShowDeleteButton="True" />
    >>
    >> <asp:TemplateField SortExpression="ProductID">
    >>
    >> <EditItemTemplate>
    >>
    >> <asp:Label ID="TextBox1" runat="server" Text='<%# Bind("ProductID")%>'
    >> Visible=false></asp:Label>
    >>
    >> </EditItemTemplate>
    >>
    >> <ItemTemplate>
    >>
    >> <asp:Label ID="Label2" runat="server" Text='<%# Bind("ProductID") %>'
    >> Visible=false></asp:Label>
    >>
    >> </ItemTemplate>
    >>
    >> </asp:TemplateField>
    >>
    >> <asp:BoundField DataField="ProductName" HeaderText="ProductName"
    >> SortExpression="ProductName" />
    >>
    >> <asp:TemplateField HeaderText="CategoryID" SortExpression="CategoryID">
    >>
    >> <EditItemTemplate>
    >>
    >> <asp:DropDownList ID="DropDownList1" runat="server"
    >> DataSourceID="SqlDataSource2"
    >>
    >> DataTextField="CategoryName" DataValueField="CategoryID"
    >> SelectedValue='<%# Bind("CategoryID") %>' >
    >>
    >> </asp:DropDownList>
    >>
    >> </EditItemTemplate>
    >>
    >> <ItemTemplate>
    >>
    >> <asp:Label ID="Label1" runat="server" Text='<%# Bind("CategoryName")
    >> %>'></asp:Label>
    >>
    >> </ItemTemplate>
    >>
    >> </asp:TemplateField>
    >>
    >> </Columns>
    >>
    >> <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
    >>
    >> <SelectedRowStyle BackColor="#D1DDF1" ForeColor="#333333"
    >> Font-Bold="True" />
    >>
    >> <PagerStyle BackColor="#2461BF" ForeColor="White"
    >> HorizontalAlign="Center" />
    >>
    >> <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
    >>
    >> <AlternatingRowStyle BackColor="White" />
    >>
    >> <RowStyle BackColor="#EFF3FB" />
    >>
    >> <EditRowStyle BackColor="#2461BF" />
    >>
    >> </asp:GridView>
    >>
    >> </form>
    >>
    >> </body>
    >>
    >> </html>
    >>
    >>

    >
    >
    verci, Aug 19, 2006
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Juan T. Llibre
    Replies:
    0
    Views:
    436
    Juan T. Llibre
    Jun 7, 2005
  2. Sql Agentman
    Replies:
    0
    Views:
    634
    Sql Agentman
    Jan 19, 2006
  3. verci

    Newbie, gridview problem Asp.net 2005

    verci, Aug 19, 2006, in forum: ASP .Net Building Controls
    Replies:
    2
    Views:
    115
    verci
    Aug 28, 2006
  4. verci

    Newbie, gridview problem ASP.net 2005

    verci, Aug 19, 2006, in forum: ASP .Net Datagrid Control
    Replies:
    4
    Views:
    132
    verci
    Aug 19, 2006
  5. verci

    Newbie, gridview problem Asp.net 2005

    verci, Aug 19, 2006, in forum: ASP .Net Datagrid Control
    Replies:
    2
    Views:
    151
    verci
    Aug 28, 2006
Loading...

Share This Page