I'm trying to add new values to my GridView, that are later passed to Cache and DataSet and underlying SQL Database.
Here is my code, but I can't figure out what to type on the line "dataRow["ID"]=" as you can see. Everything else works fine and the other values are added to the database if I just give "ID" any number that doesn't exist.
protected void insertStudent_Click(object sender, EventArgs e)
{
DataSet dataSet = (DataSet)Cache["DATASET"];
//DataRow dataRow = dataSet.Tables["Students"].Rows.Find(e.Keys["ID"]);
dataSet.Tables["Students"].PrimaryKey = new DataColumn[] { dataSet.Tables["Students"].Columns["ID"] };
DataRow dataRow = dataSet.Tables["Students"].NewRow();
dataRow["ID"] =
dataRow["FirstName"] = ((TextBox)GridView1.FooterRow.FindControl("txtFirstName")).Text;
dataRow["LastName"] = ((TextBox)GridView1.FooterRow.FindControl("txtLastName")).Text;
dataRow["Gender"] = ((DropDownList)GridView1.FooterRow.FindControl("DropDownListGender")).SelectedValue;
dataRow["Course"] = ((DropDownList)GridView1.FooterRow.FindControl("DropDownListCourse")).SelectedValue;
dataRow["Grade"] = ((DropDownList)GridView1.FooterRow.FindControl("DropDownListGrade")).SelectedValue;
Cache.Insert("DATASET", dataSet, null, DateTime.Now.AddHours(24), System.Web.Caching.Cache.NoSlidingExpiration);
dataSet.Tables["Students"].Rows.Add(dataRow);
GridView1.DataSource = (DataSet)Cache["DATASET"];
GridView1.DataBind();
}