protected void Get_RowData(object sender, GridViewCommandEventArgs e) { //int ind = GridView1.SelectedIndex; //string id = GridView1.DataKeys[ind].Value.ToString(); if (e.CommandName == "Modify") { GridViewRow row = (GridViewRow)((LinkButton)e.CommandSource).NamingContainer; int index = row.RowIndex; int employeeID = Convert.ToInt32(GridView1.DataKeys[index].Value); table1.Visible = true; // int index = Convert.ToInt32(e.CommandArgument); // string indextest = GridView1.DataKeys[Convert.ToInt32(e.CommandArgument)].Values["airid"].ToString(); SqlConnection con = new SqlConnection(connectionString); con.Open(); //SqlDataAdapter da = new SqlDataAdapter("sp_GetAir", con); DataSet ds2 = _ds.Copy(); // da.Fill(ds2); DataTable dt = ds2.Tables[0]; DataRow dr = dt.Rows[employeeID]; txtairline.Text = dr["airlines"].ToString(); txtdepcity.Text = dr["depcity"].ToString(); txtdeptime.Text = dr["deptime"].ToString(); txtdepdate.Text = dr["depdate"].ToString(); txtarrvcity.Text = dr["arrvcity"].ToString(); txtarrvtime.Text = dr["arrvtime"].ToString(); txtarrvdate.Text = dr["arrvdate"].ToString(); } }
int employeeID = Convert.ToInt32(GridView1.DataKeys[index].Value);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)