Note that there are some explanatory texts on larger screens.

plurals
  1. POGrid view Updatearguments does Not contain New Values
    primarykey
    data
    text
    <pre><code>public partial class Gridvw_expt2 : System.Web.UI.Page { SqlCommand com; SqlDataAdapter da; DataSet ds; SqlConnection con=new SqlConnection(ConfigurationManager.ConnectionStrings["gj"].ConnectionString); protected void Page_Load(object sender, EventArgs e) { com = new SqlCommand("Select * from tblExpt",con); da = new SqlDataAdapter(com); ds = new DataSet(); da.Fill(ds); if (ds.Tables[0].Rows[0] != null) { GridView1.AutoGenerateEditButton = true; GridView1.DataSource = ds; GridView1.DataBind(); GridView1.RowUpdating += new GridViewUpdateEventHandler(GridView1_RowUpdating); GridView1.DataKeyNames = new string[] { "id" }; GridView1.RowEditing += new GridViewEditEventHandler(GridView1_RowEditing); } else Response.Write("fkj"); } protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { GridViewRow row = GridView1.Rows[e.RowIndex]; int id = Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Value); string cls = ((TextBox)(row.Cells[2].Controls[0])).Text; string nam = ((TextBox)(row.Cells[3].Controls[0])).Text; foreach (DictionaryEntry entry in e.NewValues) { e.NewValues[entry.Key] = Server.HtmlEncode(entry.Value.ToString()); } com = new SqlCommand("Update tblExpt set name='" + nam + "',class='" + cls + "' where id='" + id + "'", con); da = new SqlDataAdapter(com); GridView1.EditIndex = -1; GridView1.DataSource = ds; GridView1.DataBind(); } protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e) { GridView1.EditIndex = e.NewEditIndex; GridView1.DataSource = ds; GridView1.DataBind(); } </code></pre> <p>}</p> <p>In the above code when i try to access e.new values index out of range exception is thrown.</p> <p>The table being accessed contains 3 fields id, class, name Please help to solve the problem.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload