When I click on the Alphabets ...
it will show the details of a player ...
however, when that particular letters has no details of the player ...
I want to show
"No results can be found"
Is there anyway to do it?
Thanks :D
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
ViewState["CurrentAlphabet"] = "ALL";
this.GenerateAlphabets();
this.BindDataList();
}
}
private void GenerateAlphabets()
{
List<Alphabet> alphabets = new List<Alphabet>();
Alphabet alphabet = new Alphabet();
alphabet.Value = "ALL";
alphabet.isNotSelected = !alphabet.Value
.Equals(ViewState["CurrentAlphabet"]);
alphabets.Add(alphabet);
for (int i = 65; i <= 90; i++)
{
alphabet = new Alphabet();
alphabet.Value = Char.ConvertFromUtf32(i);
alphabet.isNotSelected = !alphabet.Value
.Equals(ViewState["CurrentAlphabet"]);
alphabets.Add(alphabet);
}
rptAlphabets.DataSource = alphabets;
rptAlphabets.DataBind();
}
private void BindDataList()
{
string strConString = ConfigurationManager.ConnectionStrings["PlayersConnectionString"].ConnectionString;
SqlConnection con = new SqlConnection(strConString);
//Create command
SqlCommand cmd = new SqlCommand("Search_Players", con);
cmd.Connection = con;
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@Alphabet", ViewState["CurrentAlphabet"]);
//Open Connection
con.Open();
//Execute Command
SqlDataReader reader = cmd.ExecuteReader();
//data bind
gvPlayers.DataSource = reader;
gvPlayers.DataBind();
//close reader and connection
reader.Close();
con.Close();
if (ViewState["CurrentAlphabet"].ToString().Equals("ALL"))
lblView.Text = "all Contacts.";
else
lblView.Text = "Contacts whose name starts with "
+ ViewState["CurrentAlphabet"].ToString();
}