so how to use the like
Text='<%# Bind("Phone") %>' statement in the pivot query?
how to send sms to selected students. if write the following format in another pages it is sending the sms
<div class="table-responsive">
<asp:GridView ID="GridView1" runat="server" AllowPaging="false" Class="table table-striped table-bordered table-hover" RowStyle-Wrap="false" HeaderStyle-Wrap="false">
<Columns>
<asp:TemplateField>
<HeaderTemplate>
<asp:CheckBox ID="checkAll" runat="server" onclick = "checkAll(this);" />
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox ID="chkSelect" runat="server" onclick = "Check_Click(this)" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
con = new SqlDbConnect();
string myqry = @"DECLARE @DynamicPivotQuery AS NVARCHAR(MAX)
DECLARE @cols NVARCHAR(MAX)
SELECT @cols= ISNULL(@cols + ',','') + QUOTENAME([SubjectName])
FROM (SELECT DISTINCT SubjectName FROM tblTestSystem as sm inner join tblAssignSubjects as si on si.ASID = sm.SubjectID INNER JOIN tblDefSubject AS dsu ON si.SubjectID=dsu.SubjectID) AS Course
DECLARE @qry NVARCHAR(4000)
SET @qry =
N'
;WITH cteStudentMarksDetails
AS ( SELECT TA.AdmissionNo
,(SELECT SName FROM tblStdReg TS WHERE TS.AdmissionNo = TA.AdmissionNo) as SName
,(SELECT FName FROM tblStdReg TS WHERE TS.AdmissionNo = TA.AdmissionNo) as FName
,(SELECT SPhone FROM tblStdReg TS WHERE TS.AdmissionNo = TA.AdmissionNo) as Phone
,SUM(Marks) ObtainedMarks
,SUM([MaxMarks]) TotalMarks
,Round((SUM(Marks)) * 100/ SUM([MaxMarks]),1) as Percentage
,(CASE WHEN Round((SUM(Marks)) * 100/ SUM([MaxMarks]),1) >= 90 THEN ''A+''
WHEN Round((SUM(Marks)) * 100/ SUM([MaxMarks]),1) >= 80 THEN ''A''
WHEN Round((SUM(Marks)) * 100/ SUM([MaxMarks]),1) >= 70 THEN ''B''
WHEN Round((SUM(Marks)) * 100/ SUM([MaxMarks]),1) >= 60 THEN ''C''
WHEN Round((SUM(Marks)) * 100/ SUM([MaxMarks]),1) >= 50 THEN ''D''
WHEN Round((SUM(Marks)) * 100/ SUM([MaxMarks]),1) >= 40 THEN ''E''
ELSE ''FAIL'' END ) AS Grade
,(CASE WHEN Round((SUM(Marks)) * 100/ SUM([MaxMarks]),1) >= 90 THEN ''OutStanding''
WHEN Round((SUM(Marks)) * 100/ SUM([MaxMarks]),1) >= 80 THEN ''Excellent''
WHEN Round((SUM(Marks)) * 100/ SUM([MaxMarks]),1) >= 70 THEN ''Very Good''
WHEN Round((SUM(Marks)) * 100/ SUM([MaxMarks]),1) >= 60 THEN ''Good''
WHEN Round((SUM(Marks)) * 100/ SUM([MaxMarks]),1) >= 50 THEN ''Satisfactory''
WHEN Round((SUM(Marks)) * 100/ SUM([MaxMarks]),1) >= 40 THEN ''Work Hard''
ELSE ''FAIL'' END ) AS Remarks
FROM tblTestSystem TA
GROUP BY AdmissionNo
)
SELECT distinct AdmissionNo
,SName
,FName
,Phone
, ' + @cols + '
,ObtainedMarks
,TotalMarks
,Percentage
,Grade
,Remarks
FROM (SELECT AdmissionNo
,SubjectName
, Marks
,(SELECT ObtainedMarks FROM cteStudentMarksDetails csd Where csd.AdmissionNo = sm.AdmissionNo) as ObtainedMarks
,(SELECT Percentage FROM cteStudentMarksDetails csd Where csd.AdmissionNo = sm.AdmissionNo) as Percentage
,(SELECT TotalMarks FROM cteStudentMarksDetails csd Where csd.AdmissionNo = sm.AdmissionNo) as TotalMarks
,(SELECT Grade FROM cteStudentMarksDetails csd Where csd.AdmissionNo = sm.AdmissionNo) as Grade
,(SELECT Remarks FROM cteStudentMarksDetails csd Where csd.AdmissionNo = sm.AdmissionNo) as Remarks
,(SELECT SName FROM cteStudentMarksDetails csd Where csd.AdmissionNo = sm.AdmissionNo) as SName
,(SELECT FName FROM cteStudentMarksDetails csd Where csd.AdmissionNo = sm.AdmissionNo) as FName
,(SELECT Phone FROM cteStudentMarksDetails csd Where csd.AdmissionNo = sm.AdmissionNo) as Phone
FROM tblTestSystem as sm
inner join tblAssignSubjects as si on si.ASID = sm.SubjectID
INNER JOIN tblDefSubject AS dsu ON si.SubjectID=dsu.SubjectID
Where sm.ClassID=('+@CId+') and sm.SectionID=('+@SId+')
) p
PIVOT (MAX(Marks) FOR SubjectName IN ('+@cols+')) AS Pvt'
EXEC sp_executesql @qry;";
con.SqlQuery(myqry);
con.Cmd.Parameters.Add(new SqlParameter("@CId", this.ddlClass.SelectedValue.ToString()));
con.Cmd.Parameters.Add(new SqlParameter("@SId", this.ddlSection.SelectedValue.ToString()));
adapt.SelectCommand = con.Cmd;
adapt.Fill(sTable);
if (sTable.Rows.Count > 0)
{
GridView1.Visible = true;
GridView1.DataSource = sTable;
GridView1.DataBind();
lblTotal.Text = GridView1.Rows.Count.ToString();
}
else
{
GridView1.Visible = false;
lblTotal.Text = "0";
ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('No Record Found');", true);
return;
}
con.conClose();
<asp:TemplateField HeaderText="Applicant Name">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("StdName") %>'></asp:Label>
</ItemTemplate>
<ItemStyle HorizontalAlign="Left" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Mobile No.">
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Bind("Phone") %>'></asp:Label>
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" />
</asp:TemplateField>