Search code examples
asp.netgridviewpopupwindowlinkbutton

Gridview from button click inside a popup window


I have a text box with event name and two calendar controls to get the date and a button to display a gridview. I need to display the grid with the details like eventname start date and end date from the database..

My code is .aspx.cs

protected void lnbtnSearch_OnClick(object sender, EventArgs e)
{
      SqlConnection conn = new SqlConnection("Data Source=CTSINDLFVMOSS;Initial Catalog=DB_CGTPO_DEVE;Persist Security Info=True;User ID=*****;Password=*****");
      SqlDataAdapter adapter = new SqlDataAdapter("select EventId,EventName,StartDate,EndDate,Tactics,Perct_VolLift,Perct_ROI from  TableNamewhere  (( EventName='" + textfield3 + "') and (StartDate= StartDate) and ( EndDate= EndDate))", conn);
      DataSet ds = new DataSet();
      adapter.Fill(ds);
      grdEventDetails.DataSource = ds;
      grdEventDetails.
}

Solution

  • set grdEventDetails.AutoGenerateColumns = true; add grdEventDetails.DataBind();

    but it will look ugly (especially date fields) if you don't define the columns manually.