public void gridPaymentBind()
{
try
{
//open the db connection if it is closed...
if (connection.State == ConnectionState.Closed)
connection.Open();
command = new SqlCommand();
command.CommandText = "sp_Get_Payment";
command.CommandType = CommandType.StoredProcedure;
command.Connection = connection;
SqlDataAdapter da = new SqlDataAdapter(command);
DataSet ds = new DataSet();
da.Fill(ds);
if (ds.Tables[0].Rows.Count == 0)
{
ds.Tables[0].Rows.Add(ds.Tables[0].NewRow());
gridPaySearch.DataSource = ds;
gridPaySearch.DataBind();
int columncount = gridPaySearch.Rows[0].Cells.Count;
gridPaySearch.Rows[0].Cells.Clear();
gridPaySearch.Rows[0].Cells.Add(new TableCell());
gridPaySearch.Rows[0].Cells[0].ColumnSpan = columncount;
gridPaySearch.Rows[0].Cells[0].Text = "No Records Found";
}
else
{
gridPaySearch.DataSource = ds.Tables[0];
gridPaySearch.DataBind();
lblMessagePaySerach.Visible = false;
}
connection.Close();
}
catch (Exception ex)
{
lblMessagePaySerach.Text = ex.Message;
lblMessagePaySerach.Visible = true;
}
finally //Close db Connection if it is open....
{
if (connection.State == ConnectionState.Open)
connection.Close();
}
}
onselectedindexchanged="ddlRecordPayment_SelectedIndexChanged">
How to paging gridview on selectedvalue of dropdownlist in easy way?


Khargesh RajputRank #616 · 3.9K reputationPosted Mar 12, 2015, 9:29 PM EDT
http://www.aspsnippets.com/Articles/ASPNet-GridView-Custom-Paging-with-PageSize-Change-Dropdown.aspx
or
if you want show paging in dropdown
Use
http://www.codeproject.com/Articles/25835/GridView-Custom-Paging-with-PageSize-Change-Dropdo
Vithal WadjeRank #19 · 47.2K reputationPosted Mar 12, 2015, 10:38 AM EDT
Dawood AbbasRank #6,413 · 267 reputationPosted Mar 12, 2015, 8:53 PM EDT