Click here to Skip to main content
14,838,395 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have done gridview edit control program.
Output is displayed but when I am clicking on the edit button it is showing javascript error.

Can I know what might be the problem?

the error is:_dopostback('gridview','edit$')
provindiong the code below:

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

    </div>
    <asp:GridView ID="GridView1" runat="server" AutoGenerateEditButton="True"
        onrowediting="GridView1_RowEditing">
        <Columns>
        <asp:CommandField ShowEditButton="true" />
        <asp:BoundField  HeaderText="EMPID" DataField="emp_id" />
        <asp:BoundField  HeaderText="EMPNAME" DataField="emp_name" />
        <asp:BoundField  HeaderText="EMPSALARY" DataField="salary" />

        </Columns>

    </asp:GridView>
    </form>

C#
public partial class _Default : System.Web.UI.Page
{
    DataSet ds = new DataSet();
    protected void Page_Load(object sender, EventArgs e)
    {
        SqlConnection conn = new SqlConnection("Data source=10.0.2.8; user id=sa; password=change_123; database=sample");
        conn.Open();
        SqlDataAdapter da = new SqlDataAdapter("select * from emp", conn);
        DataSet ds = new DataSet();
        da.Fill(ds, "emp");
        if (IsPostBack==false)
        {
            GridView1.DataSource = ds.Tables[0];
            GridView1.DataBind();
        }
    }
    
    protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
    {
        GridView1.EditIndex = e.NewEditIndex;
        GridView1.DataSource = ds.Tables[0];
        GridView1.DataBind();
    }
}


Thanks in advance
Posted
Updated 28-Sep-10 22:50pm
v5
Comments
Toniyo Jackson 29-Sep-10 2:46am
   
can u tell me what error msg u r getting?
Prosanta Kundu online 29-Sep-10 2:47am
   
What error are you getting? Provide the error details.
Sunasara Imdadhusen 29-Sep-10 2:54am
   
Whenever you ask questions to community, please represent it very clearly so you can get answer very quickly.
Dalek Dave 29-Sep-10 3:40am
   
Minor Edit for Grammar.
Sushant Joshi 29-Sep-10 6:12am
   
Could you please provide details of the JS error

1 solution

You have not provided where you have defined the Javascript code related to your question but one thing that I noticed in your error detail is '_dopostback'
VB
the error is:_dopostback('gridview','edit$')


It should be __doPostback. Looks like you are tryng for forced postback from Javascript. If so, use double underscore before the doPostback thing.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900