with this one you people can get ur expected output, Simply paste this code into ur aspx & aspx.cs pages u will get output
ckeckboxes.aspx
=============
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>Untitled Page</title>
<script language="javascript" type="text/javascript">
function ChangeCheckBoxState(id, checkState)
{
var cb = document.getElementById(id);
if (cb != null)
cb.checked = checkState;
}
function HeaderCheckbox(chkHeader)
{
var cb = document.getElementById(chkHeader);
if(cb != null)
{
if(cb.checked)
{
checkAll('1');
}
else
checkAll('0');
}
}
function checkAll(checkStates)
{
var checkState = false;
if(checkStates == 1)
checkState = true;
if (AllCheckBoxs != null)
{
for (var i = 0; i < AllCheckBoxs.length; i++)
ChangeCheckBoxState(AllCheckBoxs[i], checkState);
}
}
function popups()
{
window.open("..\Admin\ViewDatagridDetails.aspx","mywindow","menubar=0,resizable=0,width=350,height=250,scrollbars=yes,resizable=yes");
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<%-- <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:LITHostingConnectionString %>"
SelectCommand="SELECT * FROM [tblEnquiry]"></asp:SqlDataSource>--%>
<asp:Button ID="btnSubmit" runat="server" OnClick="btnSubmit_Click" Style="z-index: 100;
left: 24px; position: absolute; top: 116px" Text="View Enquiry Details" />
<asp:Panel ID="Laxmi" runat="server" BackColor="#E0E0E0" Font-Bold="True" Font-Italic="True"
Font-Size="X-Large" ForeColor="Red" Height="82px" Style="z-index: 101; left: 0px;
position: absolute; top: 0px" Width="200%">
<br />
Laxmi Hosting Administrator Panel</asp:Panel>
<asp:Label ID="lblTotalRows" runat="server" Style="z-index: 102; left: 37px; position: absolute;
top: 86px"></asp:Label>
<asp:GridView ID="gvDetails" runat="server" BackColor="#DEBA84" BorderColor="#DEBA84"
BorderStyle="None" BorderWidth="1px" CellPadding="3" CellSpacing="2" Style="z-index: 103;
left: 15px; position: absolute; top: 157px" AutoGenerateColumns="False">
<FooterStyle BackColor="#F7DFB5" ForeColor="#8C4510" />
<RowStyle BackColor="#FFF7E7" ForeColor="#8C4510" />
<SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="White" />
<PagerStyle ForeColor="#8C4510" HorizontalAlign="Center" />
<HeaderStyle BackColor="#A55129" Font-Bold="True" ForeColor="White" />
<Columns >
<asp:TemplateField >
<HeaderTemplate>
<asp:CheckBox ID="chkHeader" runat="server" />
</HeaderTemplate>
<ItemTemplate >
<asp:CheckBox ID="chkCheck" runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText = "EnquiryID">
<ItemTemplate >
<asp:Label ID="lblEnquiryId" runat="server" Text='<%# GetData(Eval("EnquiryID")) %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText = "Name" >
<ItemTemplate >
<asp:Label ID="lblName" runat="server" Text='<%# GetData(Eval("Name")) %>' Visible="true" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText = "Email ID" >
<ItemTemplate >
<asp:Label ID="lblEmail" runat="server" Text='<%# GetData(Eval("Email")) %>' Visible="true" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText = "Mobile No." >
<ItemTemplate >
<asp:Label ID="lblMobile" runat="server" Text='<%# GetData(Eval("Mobile")) %>' Visible="true" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText = "URL" >
<ItemTemplate >
<asp:Label ID="lblURL" runat="server" Text='<%# GetData(Eval("URL")) %>' Visible="true" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText = "Landline" Visible="False" >
<ItemTemplate >
<asp:Label ID="lblLandline" runat="server" Text='<%# GetData(Eval("Landline")) %>' Visible="false" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText = "Country" Visible="False" >
<ItemTemplate >
<asp:Label ID="lblCountry" runat="server" Text='<%# GetData(Eval("Country")) %>' Visible="false" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText = "Address" Visible="False" >
<ItemTemplate >
<asp:Label ID="lblAddress" runat="server" Text='<%# GetData(Eval("Address")) %>' Visible="false" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText = "Platform" Visible="False" >
<ItemTemplate >
<asp:Label ID="lblPlatform" runat="server" Text='<%# GetData(Eval("Platform")) %>' Visible="false" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText = "HostingPlan" Visible="False" >
<ItemTemplate >
<asp:Label ID="lblHostingPlan" runat="server" Text='<%# GetData(Eval("HostingPlan")) %>' Visible="false" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText = "No. of Years" Visible="False" >
<ItemTemplate >
<asp:Label ID="lblYears" runat="server" Text='<%# GetData(Eval("Years")) %>' Visible="false" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText = "WebsiteSize" Visible="False" >
<ItemTemplate >
<asp:Label ID="lblWebsiteSize" runat="server" Text='<%# GetData(Eval("WebsiteSize")) %>' Visible="false" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText = "RegistrationType" Visible="False" >
<ItemTemplate >
<asp:Label ID="lblRegistrationType" runat="server" Text='<%# GetData(Eval("RegistrationType")) %>' Visible="false" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText = "ServiceType" Visible="False" >
<ItemTemplate >
<asp:Label ID="lblServiceType" runat="server" Text='<%# GetData(Eval("ServiceType")) %>' Visible="false" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText = "Description" Visible="False" >
<ItemTemplate >
<asp:Label ID="lblDescription" runat="server" Text='<%# GetData(Eval("Description")) %>' Visible="false" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText = "LITKnowsBy" Visible="False" >
<ItemTemplate >
<asp:Label ID="lblLITKnowsBy" runat="server" Text='<%# GetData(Eval("LITKnowsBy")) %>' Visible="false" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="View Profile">
<ItemTemplate>
<asp:HyperLink ID="hplViewEmpleyerProfile" runat="server" Text="View" NavigateUrl='<%# NavigateToViewPostedJob(Eval("EnquiryID")) %>'>
</asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:LITHostingConnectionString %>"
SelectCommand="SELECT [EnquiryID], [Name] FROM [tblEnquiry]"></asp:SqlDataSource>
<asp:Button ID="btnReplyMail" runat="server" Style="z-index: 104; left: 295px; position: absolute;
top: 114px" Text="Reply For Selected One" />
<asp:Button ID="btnSendMail" runat="server" Style="z-index: 105; left: 518px; position: absolute;
top: 118px" Text="Send Mail To Selected People" />
<asp:Button ID="btnTest" runat="server" OnClick="btnTest_Click" Style="z-index: 106;
left: 814px; position: absolute; top: 118px" Text="Test" />
<asp:Label ID="lblStatus" runat="server" Style="z-index: 107; left: 22px; position: absolute;
top: 368px"></asp:Label>
<asp:Label ID="lblStoreName" runat="server" Style="z-index: 108; left: 87px; position: absolute;
top: 409px"></asp:Label>
</div>
</form>
</body>
</html>
ckeckboxes.aspx.cs
===============
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Configuration;
using System.Data.SqlClient;
using System.Text;
public partial class Admin_Datagridtest : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
string constring = ConfigurationSettings.AppSettings["constring"];
SqlConnection con = new SqlConnection(constring);
con.Open();
SqlCommand cmd = new SqlCommand("select * from tblEnquiry", con);
SqlDataReader dr;
dr = cmd.ExecuteReader();
if (dr.Read())
{
gvDetails.DataSource = dr;
gvDetails.DataBind();
//foreach (GridViewRow gvRow in gvDetails.Rows)
//{
// CheckBox cb = (CheckBox)gvRow.FindControl("chkCheck");
// ClientScript.RegisterArrayDeclaration("AllCheckBoxes", "'" + cb.ClientID + "'");
//}
dr.Close();
}
string sql = "select count(*) from tblEnquiry";
SqlCommand cmd1 = new SqlCommand(sql, con);
lblTotalRows.Text = "Total No. of Records in Enquiry form is :" + cmd1.ExecuteScalar();
con.Close();
}
public string GetData(object o)
{
string str = Convert.ToString(o);
if ((str == null) || (str == string.Empty) || (str == "-1.00"))
return "-";
else
return str.Trim();
}
public string NavigateToViewPostedJob(object o)
{
string str = o.ToString();
//Session["Employer"] = str;
//Label lblEnquiryIdVal = (Label)myCbSelected.FindControl("lblEnquiryId");
//Label lblNameVal = (Label)myCbSelected.FindControl("lblName");
//Label lblEmailVal = (Label)myCbSelected.FindControl("lblEmail");
//Label lblMobileVal = (Label)myCbSelected.FindControl("lblMobile");
//Label lblLandlineVal = (Label)myCbSelected.FindControl("lblLandline");
//Label lblCountryVal = (Label)myCbSelected.FindControl("lblCountry");
//Label lblAddressVal = (Label)myCbSelected.FindControl("lblAddress");
//Label lblPlatformVal = (Label)myCbSelected.FindControl("lblPlatform");
//Label lblHostingPlanVal = (Label)myCbSelected.FindControl("lblHostingPlan");
//Label lblYearsVal = (Label)myCbSelected.FindControl("lblYears");
//Label lblURLVal = (Label)myCbSelected.FindControl("lblURL");
//Label lblWebsiteSizeVal = (Label)myCbSelected.FindControl("lblWebsiteSize");
//Label lblRegistrationTypeVal = (Label)myCbSelected.FindControl("lblRegistrationType");
//Label lblServiceTypeVal = (Label)myCbSelected.FindControl("lblServiceType");
//Label lblDescriptionVal = (Label)myCbSelected.FindControl("lblDescription");
//Label lblLITKnowsByVal = (Label)myCbSelected.FindControl("lblLITKnowsBy");
//lblStoreName.Text += "<html>" + " You Have Selected :" +
// "<body>" +
// "<table border=\"1\" bordercolor=\"red\" align=\"center\" cellpadding=\"2\" cellspacing=\"2\" width=\"100%\">" +
// "<tr>" +
// "<td>" +
// "<table border=\"0\" align=\"center\" cellpadding=\"2\" cellspacing=\"2\" width=\"100%\bgcolor=\"green\">" +
// "<tr>" +
// "<tr>" +
// "<td><p> Enquiry ID</p> </td>" +
// "<td width=\"35\"><div align=\"center\"> :</div></td>" +
// "<td >" + lblEnquiryIdVal.Text + "</td>" +
// "</tr>" +
// "<tr>" +
// "<td><p> Name </p></td>" +
// "<td width=\"35\"><div align=\"center\">:</div></td>" +
// "<td >" + lblNameVal.Text + "</td>" +
// "</tr>" +
// "<tr>" +
// "<td><p> Email ID</p> </td>" +
// "<td width=\"35\"><div align=\"center\"> :</div></td>" +
// "<td >" + lblEmailVal.Text + "</td>" +
// "</tr>" +
// "<tr>" +
// "<td><p> Mobile No</p> </td>" +
// "<td width=\"35\"><div align=\"center\">:</div></td>" +
// "<td >" + lblMobileVal.Text + "</td>" +
// "</tr>" +
// "<tr>" +
// "<td><p>Landline</p></td>" +
// "<td width=\"35\"><div align=\"center\">:</div></td>" +
// "<td >" + lblLandlineVal.Text + "</td>" +
// "</tr>" +
// "<tr>" +
// "<td><p>Country</p></td>" +
// "<td width=\"35\"><div align=\"center\">:</div></td>" +
// "<td >" + lblCountryVal.Text + "</td>" +
// "</tr>" +
// "<tr>" +
// "<td><p>Address</p></td>" +
// "<td width=\"35\"><div align=\"center\">:</div></td>" +
// "<td >" + lblAddressVal.Text + "</td>" +
// "</tr>" +
// "<tr>" +
// "<td><p>Platform</p></td>" +
// "<td width=\"35\"><div align=\"center\">:</div></td>" +
// "<td >" + lblPlatformVal.Text + "</td>" +
// "</tr>" +
// "<tr>" +
// "<td><p>Hosting Plan</p></td>" +
// "<td width=\"35\"><div align=\"center\">:</div></td>" +
// "<td >" + lblHostingPlanVal.Text + "</td>" +
// "</tr>" +
// "<tr>" +
// "<td><p>Years </p></td>" +
// "<td width=\"35\"><div align=\"center\">:</div></td>" +
// "<td >" + lblYearsVal.Text + "</td>" +
// "</tr>" +
// "<tr>" +
// "<td><p>Domain Name</p></td>" +
// "<td width=\"35\"><div align=\"center\">:</div></td>" +
// "<td >" + lblURLVal.Text + "</td>" +
// "</tr>" +
// "<tr>" +
// "<td><p>Site Size</p></td>" +
// "<td width=\"35\"><div align=\"center\">:</div></td>" +
// "<td >" + lblWebsiteSizeVal.Text + "</td>" +
// "</tr>" +
// "<tr>" +
// "<td><p>Registration Type </p></td>" +
// "<td width=\"35\"><div align=\"center\">:</div></td>" +
// "<td >" + lblRegistrationTypeVal.Text + "</td>" +
// "</tr>" +
// "<tr>" +
// "<td><p>Type Of Services Requesting</p></td>" +
// "<td width=\"35\"><div align=\"center\">:</div></td>" +
// "<td >" + lblServiceTypeVal.Text + "</td>" +
// "</tr>" +
// "<tr>" +
// "<td><p>Description</p></td>" +
// "<td width=\"35\"><div align=\"center\">:</div></td>" +
// "<td >" + lblDescriptionVal.Text + "</td>" +
// "</tr>" +
// "<tr>" +
// "<td><p>Laxmi Hosting Knows By</p></td>" +
// "<td width=\"35\"><div align=\"center\">:</div></td>" +
// "<td >" + lblLITKnowsByVal.Text + "</td>" +
// "</tr>" +
// "</table>" +
// "</td>" +
// "</tr>" +
// "</table>" +
// "</body>" +
// "</html>";
Session["rec"] = lblStoreName.Text;
return "ViewDatagridDetails.aspx?RecordID=" + str.Trim();
}
protected void btnTest_Click(object sender, EventArgs e)
{
lblStatus.Text = "";
lblStoreName.Text = "";
lblStatus.Text = "<br>You selected the Following items:<br><br>";
StringBuilder EnquiryIds = new StringBuilder();
foreach (GridViewRow myCbSelected in gvDetails.Rows)
{
CheckBox chkSelected = (CheckBox)myCbSelected.FindControl("chkCheck");
if (chkSelected.Checked == true)
{
Label lblEnquiryIdVal = (Label)myCbSelected.FindControl("lblEnquiryId");
Label lblNameVal = (Label)myCbSelected.FindControl("lblName");
Label lblEmailVal = (Label)myCbSelected.FindControl("lblEmail");
Label lblMobileVal = (Label)myCbSelected.FindControl("lblMobile");
Label lblLandlineVal = (Label)myCbSelected.FindControl("lblLandline");
Label lblCountryVal = (Label)myCbSelected.FindControl("lblCountry");
Label lblAddressVal = (Label)myCbSelected.FindControl("lblAddress");
Label lblPlatformVal = (Label)myCbSelected.FindControl("lblPlatform");
Label lblHostingPlanVal = (Label)myCbSelected.FindControl("lblHostingPlan");
Label lblYearsVal = (Label)myCbSelected.FindControl("lblYears");
Label lblURLVal = (Label)myCbSelected.FindControl("lblURL");
Label lblWebsiteSizeVal = (Label)myCbSelected.FindControl("lblWebsiteSize");
Label lblRegistrationTypeVal = (Label)myCbSelected.FindControl("lblRegistrationType");
Label lblServiceTypeVal = (Label)myCbSelected.FindControl("lblServiceType");
Label lblDescriptionVal = (Label)myCbSelected.FindControl("lblDescription");
Label lblLITKnowsByVal = (Label)myCbSelected.FindControl("lblLITKnowsBy");
lblStoreName.Text += "<html>" + " You Have Selected :" +
"<body>" +
"<table border=\"1\" bordercolor=\"red\" align=\"center\" cellpadding=\"2\" cellspacing=\"2\" width=\"100%\">" +
"<tr>" +
"<td>" +
"<table border=\"0\" align=\"center\" cellpadding=\"2\" cellspacing=\"2\" width=\"100%\bgcolor=\"green\">" +
"<tr>" +
"<tr>" +
"<td><p> Enquiry ID</p> </td>" +
"<td width=\"35\"><div align=\"center\"> :</div></td>" +
"<td >" + lblEnquiryIdVal.Text + "</td>" +
"</tr>" +
"<tr>" +
"<td><p> Name </p></td>" +
"<td width=\"35\"><div align=\"center\">:</div></td>" +
"<td >" + lblNameVal.Text + "</td>" +
"</tr>" +
"<tr>" +
"<td><p> Email ID</p> </td>" +
"<td width=\"35\"><div align=\"center\"> :</div></td>" +
"<td >" + lblEmailVal.Text + "</td>" +
"</tr>" +
"<tr>" +
"<td><p> Mobile No</p> </td>" +
"<td width=\"35\"><div align=\"center\">:</div></td>" +
"<td >" + lblMobileVal.Text + "</td>" +
"</tr>" +
"<tr>" +
"<td><p>Landline</p></td>" +
"<td width=\"35\"><div align=\"center\">:</div></td>" +
"<td >" + lblLandlineVal.Text + "</td>" +
"</tr>" +
"<tr>" +
"<td><p>Country</p></td>" +
"<td width=\"35\"><div align=\"center\">:</div></td>" +
"<td >" + lblCountryVal.Text + "</td>" +
"</tr>" +
"<tr>" +
"<td><p>Address</p></td>" +
"<td width=\"35\"><div align=\"center\">:</div></td>" +
"<td >" + lblAddressVal.Text + "</td>" +
"</tr>" +
"<tr>" +
"<td><p>Platform</p></td>" +
"<td width=\"35\"><div align=\"center\">:</div></td>" +
"<td >" + lblPlatformVal.Text + "</td>" +
"</tr>" +
"<tr>" +
"<td><p>Hosting Plan</p></td>" +
"<td width=\"35\"><div align=\"center\">:</div></td>" +
"<td >" + lblHostingPlanVal.Text + "</td>" +
"</tr>" +
"<tr>" +
"<td><p>Years </p></td>" +
"<td width=\"35\"><div align=\"center\">:</div></td>" +
"<td >" + lblYearsVal.Text + "</td>" +
"</tr>" +
"<tr>" +
"<td><p>Domain Name</p></td>" +
"<td width=\"35\"><div align=\"center\">:</div></td>" +
"<td >" + lblURLVal.Text + "</td>" +
"</tr>" +
"<tr>" +
"<td><p>Site Size</p></td>" +
"<td width=\"35\"><div align=\"center\">:</div></td>" +
"<td >" + lblWebsiteSizeVal.Text + "</td>" +
"</tr>" +
"<tr>" +
"<td><p>Registration Type </p></td>" +
"<td width=\"35\"><div align=\"center\">:</div></td>" +
"<td >" + lblRegistrationTypeVal.Text + "</td>" +
"</tr>" +
"<tr>" +
"<td><p>Type Of Services Requesting</p></td>" +
"<td width=\"35\"><div align=\"center\">:</div></td>" +
"<td >" + lblServiceTypeVal.Text + "</td>" +
"</tr>" +
"<tr>" +
"<td><p>Description</p></td>" +
"<td width=\"35\"><div align=\"center\">:</div></td>" +
"<td >" + lblDescriptionVal.Text + "</td>" +
"</tr>" +
"<tr>" +
"<td><p>Laxmi Hosting Knows By</p></td>" +
"<td width=\"35\"><div align=\"center\">:</div></td>" +
"<td >" + lblLITKnowsByVal.Text + "</td>" +
"</tr>" +
"</table>" +
"</td>" +
"</tr>" +
"</table>" +
"</body>" +
"</html>";
//lblStoreName.Text += lblEnquiryIdVal.Text + "," + lblNameVal.Text + "," + lblMobileVal.Text + "," + lblURLVal.Text + "<br>";
//string s=Convert.ToString(lblStoreName.Text);
//Response.Write(s);
Session["rec"] = lblStoreName.Text;
}
}
}
protected void gvDetails_DataBound(object sender, EventArgs e)
{
CheckBox cb = (CheckBox)gvDetails.HeaderRow.FindControl("chkHeader");
cb.Attributes.Add("onclick", "HeaderCheckbox('" + cb.ClientID + "')");
}
}