I have a button which is inside the datalist,te datalist which is inside the Gridview.
protected void rptrbus_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
string id = rptrbus.DataKeys[e.Row.RowIndex].Value.ToString();
// Session["id"] = id.ToString();
DataList dlseat = e.Row.FindControl("dlSeat") as DataList;
string strConnString = ConfigurationManager.ConnectionStrings["str"].ConnectionString;
using (SqlConnection con = new SqlConnection(strConnString))
{
SqlCommand cmd = new SqlCommand("sp_Trial1", con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
cmd.CommandType = System.Data.CommandType.StoredProcedure;
// string id = HttpContext.Current.Session["id"].ToString();
cmd.Parameters.AddWithValue("@id", id);
DataTable dt = new DataTable();
da.Fill(dt);
dlseat.DataSource = dt;
dlseat.DataBind();
}
}