2013-01-05 49 views
1

我正在從GridView的數據製作Crystal-ReportGridView有三列,其中兩列用來自DataBase的值填充到標籤中,第三列有一個CheckBox,它將這兩列的值作爲查詢字符串發送到Crystal-Report的.cs頁面。列值由存儲過程使用,然後結果顯示在Crystal-Report中。 現在我的問題是,如果用戶檢查兩個CheckBox那麼兩列的值應該作爲數組發送到Crystal-Report頁面。如何GridView頁面後面實現這個如何發送數組中的查詢字符串的值

我的代碼是

protected void ChkCity_CheckedChanged(object sender, EventArgs e) 
    { 
    foreach (GridViewRow row in gdCityDetail.Rows) 
     { 
bool ischecked = ((System.Web.UI.WebControls.CheckBox)row.Cells[0].FindControl("CheckBox2")).Checked; 
      if (ischecked == true) 
{ 
int getrow = Convert.ToInt32(e.CommandArgument); 
    Label label1 = (Label)gdVilDetail.Rows[getrow].FindControl("label1"); 
       Label label2= (Label)gdVilDetail.Rows[getrow].FindControl("label2"); 

       Response.Redirect("~/crystal report/Landowner.aspx?Yojna=" + label1.text + "&Village=" + label2.text); 

      } 

和的.cs的Crystal-Report頁上的代碼被

private void cityreport() 
    { 
     SqlCommand Cmd = new SqlCommand("Showvillage", Constr1); 
     Cmd.CommandType = CommandType.StoredProcedure; 
     Cmd.Parameters.Add("@Yojna_No", Request.QueryString[0]); 
     Cmd.Parameters.Add("@Village_Code", Request.QueryString[1]); 
     DataSet ds = new DataSet(); 

回答

2

我認爲你不能傳遞數組或任何其他對象通過查詢字符串,除字符串值外而是您可以使用會話變量。

試試這個..

在一個頁面中。

//Set 
Session["Variable"] = ArrayObj; 

In page two。

//If String[] 

string[] arry = (string[])Session["Variable"]; 

希望它有助於..

相關問題