I have designed the Gridview as below...
<asp:GridView ID="GV_Test" runat="server" AutoGenerateColumns="false">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<table>
<tr>
<td colspan="2" align="center">
<asp:CheckBox ID="chk" runat="server" AutoPostBack="true" OnCheckedChanged="chk_CheckedChanged" /></td>
</tr>
<tr>
<td align="left"><strong>Organization :</strong><asp:Label ID="lbl_Org" runat="server" Text='<%#Eval("Name") %>'></asp:Label>
</td>
</tr>
<tr>
<td align="left"><strong>Address :</strong><asp:Label ID="lbl_address" runat="server" Text='<%#Eval("Addres") %>'></asp:Label>
</td>
</tr>
<tr>
<td colspan="2" align="left"></td>
</tr>
<tr>
<td align="left"><strong>Phone :</strong><asp:Label ID="lbl_Phone" runat="server" Text='<%#Eval("Phone") %>'></asp:Label>
</tr>
<tr>
<td align="left"><strong>Email :</strong><asp:Label ID="lbl_Email" runat="server" Text='<%#Eval("Email") %>'></asp:Label>
</tr>
</table>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
I need to display the result vertically, all the columns of the the selected row in the gridview should be grouped together and then display vertically When i select the check box in the GridView, in simple words i have to show the result as like DataList in next page.
The output has come horizotally when i follow the below code..
protected void Btn_REsult_Click(object sender, EventArgs e)
{
DataTable dt = new DataTable();
dt.Columns.Add("Organization", typeof(string));
dt.Columns.Add("Address", typeof(string));
dt.Columns.Add("Phone", typeof(string));
dt.Columns.Add("Email", typeof(string));
int len = GV_Test.Rows.Count;
for (int i = 0; i < len; i++)
{
CheckBox chk = (CheckBox)GV_Test.Rows[i].FindControl("chk");
Label lbl_Org = (Label)GV_Test.Rows[i].FindControl("lbl_Org");
Label lbl_address = (Label)GV_Test.Rows[i].FindControl("lbl_address");
Label lbl_Phone = (Label)GV_Test.Rows[i].FindControl("lbl_Phone");
Label lbl_Email = (Label)GV_Test.Rows[i].FindControl("lbl_Email");
if (chk.Checked)
{
DataRow row = dt.NewRow();
row["Organization"] = Convert.ToString(lbl_Org.Text);
row["Address"] = Convert.ToString(lbl_address.Text);
row["Phone"] = Convert.ToString(lbl_Phone.Text);
row["Email"] = Convert.ToString(lbl_Email.Text);
dt.Rows.Add(row);
}
}
Session["Res"] = dt;
Response.Redirect("testing.aspx");
}