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?
3 Replies
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.

Khargesh RajputPosted Mar 13, 2015, 1:29 AM
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
Dawood AbbasPosted Mar 13, 2015, 12:53 AM
Vithal WadjePosted Mar 12, 2015, 2:38 PM