I have a Gridview with Name Gridview1
I have a SqlDatasource with Name SqlDatasource1
I have a TextBox which can search SqlDatasource1
i have code like below
protected void ButtonSearch_Click(object sender, EventArgs e)
{
SqlDataSource1.SelectCommand = "SELECT *FROM GOMSNO747 WHERE APPLICATIONNO='" + TextBoxApplicantionNumber.Text + "'";
}
It works well when Record Found
When No Record Found I need to Show a Label with the Name No Record Found
I used <emptydatatemplate>No Record Found
The Problem is it sinks GridView Caption and No Record Found have a line around
In order to solve this i used below code
protected void SqlDataSource1_Selected(object sender, SqlDataSourceStatusEventArgs e)
{
if (e.AffectedRows == 0)
{
LabelNoRecord.Text = "No Record Found";
}
}
But the Problem is it display No Record even if the Record is Founded also
The Reason is SELECT command is not effect the Rows
How to solve this Problem