roXy101208 0 Newbie Poster

Hi guys, i just want to know in ASP. net how do I run without error when I click the edit button in the gridview then another page will appear to update and save. heres the code. Can anyone help me.? Thanks.

CODE ASP. NET

<asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
        AutoGenerateColumns="False" DataKeyNames="vendorCode" DataSourceID="ds_vendor" 
        Width="782px">
        <Columns>
            <asp:BoundField DataField="vendorCode" HeaderText="Vendor Code" ReadOnly="True" 
                SortExpression="vendorCode" />
            <asp:BoundField DataField="vendorname" HeaderText="Vendor Name" 
                SortExpression="vendorname" />
            <asp:BoundField DataField="address" HeaderText="Address" 
                SortExpression="address" />
            <asp:BoundField DataField="phonenumber" HeaderText="Phone Number" 
                SortExpression="phonenumber" />
            <asp:BoundField DataField="emailAddress" HeaderText="Email Address" 
                SortExpression="emailAddress" />
            <asp:ButtonField ButtonType="Image" CommandName="Selection" Text="View" />
            <asp:ButtonField ButtonType="Image" CommandName="Edit" Text="Edit" />
            <asp:ButtonField ButtonType="Image" CommandName="Delete" Text="Delete" />
        </Columns>
    </asp:GridView>

C#

public partial class index : System.Web.UI.Page
{
    public string sql_command = "SELECT * FROM [tblVendors]";

    protected void Page_Load(object sender, EventArgs e)
    {
        lPageTitle.Text = "Vendor Maintenance";

        load_vendors();
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (t_searchkey.Text != "")
        {
            sql_command += " WHERE divisioncode = '" + t_searchkey.Text.Trim() + "'";
            // sql_command += " WHERE companycode = '" + t_searchkey.Text.Trim() + "'";
            load_vendors();
        }
    }
    void load_vendors()
    {
        ds_vendor.SelectCommand = sql_command;
    }

Thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.