I have a big mistake in rowcommand. I have a button field with commandname "add". When I click it the code doesn't fire the first time but click it again and the code fires!
if (e.CommandName == "add")
{
DataClassesDataContext db = new DataClassesDataContext();
int ii = int.Parse(e.CommandArgument.ToString());
int num = int.Parse(((TextBox)GridView1.Rows[ii].FindControl("TextBox2")).Text);
string id = GridView1.Rows[ii].Cells[0].Text;
temp t = new temp();
t.tedad = num;
t.username = Session["username"].ToString();
db.temps.InsertOnSubmit(t);
db.SubmitChanges();
}
rowcommand dose not fire when clicking the first time!
You should bound the Datasource to Gridview on postback.