title: how to get gridview textbox value in crystal report in asp.net c#
body: <p>i stuck again in asp.net.. i'm creating a website in which people purchases items selecting category(Database created in sql server tale name is items and category is its field) from dropdownlist and shows into a 1st GridView. Buyer check the items from 1st Gridview and click select button and those selected items shows in 2nd Gridview. And 2nd Gridview has TemplateField Textbox and it take Quantity item purchased.</p>
  
  <p>What i want is when i click generate report the gridview2 textbox value should display Quantity purchased by buyer in crystal report.</p>
  
  <p>i only need to do this only i have no problem getting item names in report but i can't get values of gridview textboxes. 
  i Googled but no luck....</p>
  
  <p>anyone can help me with example please..i'm working on c#</p>
  
  <p>I tried this</p>
  
  <pre><code> protected void Button1_Click(object sender, EventArgs e)
   {
      List&lt;string&gt; checkedIDs = new List&lt;string&gt;();
  
      for (int i = 0; i &lt; GridView1.Rows.Count; i++)
      {
          CheckBox chbox = GridView1.Rows[i].Cells[0].FindControl("CheckBox1") as CheckBox;
          if (chbox.Checked == true)
          {
              checkedIDs.Add("'" + GridView1.Rows[i].Cells[1].Text + "'"); 
  
          }
  
      }
      string conn = ConfigurationManager.ConnectionStrings["Test_T3ConnectionString2"].ConnectionString;
      SqlConnection con = new SqlConnection(conn);
      string query = "select prod_name,price from products where prod_id in (" + string.Join(",", checkedIDs.ToArray()) + ")"; 
      SqlCommand cmd = new SqlCommand(query, con);
      SqlDataAdapter da = new SqlDataAdapter(cmd);
      DataSet1 ds = new DataSet1(); 
      da.Fill(ds.Tables["Purchase_Report"]);
  
      GridView2.DataSource = ds;
      GridView2.DataBind();
      ViewState["Records"] = ds;
  
  }
  
  
  
  
  protected void Button2_Click(object sender, EventArgs e)
  {
  
      ReportDocument rd = new ReportDocument();
      rd.Load(Server.MapPath("CrystalReport.rpt"));
      rd.SetDataSource(ViewState["Records"]);
      rd.SetDatabaseLogon("sa", "abc", "localhost", "Test_T3");
      rd.SetParameterValue("Quantity",GridView2.Rows[0].Cells[0].FindControl("TextBox1")); //this is what i tried, Quantity is a parameter i created in my crystal report
  
      CrystalReportViewer1.ReportSource = rd;
      CrystalReportViewer1.DataBind();
  
  }
  </code></pre>
  
  <p>Thanks</p>