I have to get start date and end date from two text box and fetch the data from in between that dates and shown into a grid view

protected void Button1_Click(object sender, EventArgs e)
    String str = DateTime.Now.ToString(TextBox1.Text);
    DateTime tm = Convert.ToDateTime(str);
    String str2 = DateTime.Now.ToString(TextBox2.Text);
    DateTime tm2 = Convert.ToDateTime(str2);

    solarDataSet2TableAdapters.tbl_energy_reportTableAdapter state;
    state = new solarDataSet2TableAdapters.tbl_energy_reportTableAdapter();

    DataTable dt = new DataTable();  
    dt = state.GetGridDataBy(DropDownList1.SelectedValue,DropDownList2.SelectedValue,  

    str, str2);  // Failed to enable constraints. One or more rows contain values  
    //violating non-null, unique, or foreign-key constraints. asp.net c#  

    GridView1.DataSource = dt;

Related posts

Recent Viewed