Hi Team I want to send column field and Row field of selected value of pivot result to another page through button. In Gridview I was able to get the selected values from button, but that values are not passing to another page till I again click on show button. my code protected void Button2_Click(object sender, EventArgs e) { SqlConnection sqlConnection = new SqlConnection(strSQLconnection); SqlCommand sqlCommand = new SqlCommand("SELECT * FROM ( SELECT CUST, PRODUCT, cast(QTY as int) as QTY FROM Product) up PIVOT (SUM(QTY) FOR PRODUCT IN (VEG, SODA, MILK, BEER, CHIPS)) AS pvt ORDER BY CUST", sqlConnection); sqlConnection.Open(); SqlDataReader reader = sqlCommand.ExecuteReader(); Gridview1.DataSource = reader; Gridview1.DataBind(); } private List<string> _headers = new List<string>(); protected void Gridview1_RowDataBound(object sender, GridViewRowEventArgs e) { //Collect the texts from the column headers if (e.Row.RowType == DataControlRowType.Header) { for (int i = 0; i <= e.Row.Cells.Count - 1; i++) { this._headers.Add(e.Row.Cells[i].Text); } } if (e.Row.RowType == DataControlRowType.DataRow) { for (int i = 0; i <= e.Row.Cells.Count - 1; i++) { if (TryToParse(e.Row.Cells[i].Text) > 0) { string rowKey = e.Row.Cells[0].Text; string column = this._headers[i]; Button link = new Button(); link.BackColor=Color.White; link.BorderStyle = BorderStyle.None; link.Text = e.Row.Cells[i].Text; link.PostBackUrl = "Default.aspx?key=" + rowKey + "&column=" + column; e.Row.Cells[i].Controls.Clear(); e.Row.Cells[i].Controls.Add(link); string Name = Request.QueryString["key"]; string Column = Request.QueryString["column"]; if (Name != null && Column != null) { Page.ClientScript.RegisterStartupScript(GetType(), "", "window.open('Default2.aspx?key=" + Name + "&column=" + Column + "','','width=500,height=300');", true); } } } } } private int TryToParse(string value) { int number; bool result = Int32.TryParse(value, out number); if (result) return number; else return 0; } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)