I have code to have a dynamic button appear after it does an if else loop for checking for some data.
however, the gridview cant do any paging. it only shows the first page and cant go to 2nd page and so on.
It only can do the paging IF i nvr call the method below.
here is my code
public void filter_select(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
........
}
that method will be called on the rowdatabound gridview page source like this OnRowDataBound="filter_select"
my gridview code on source code is :
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" CellPadding="2" CellSpacing="2"
HorizontalAlign="Center" OnRowCommand="stop_survey"
OnRowDataBound="filter_select" OnSelectedIndexChanging="selected" PageSize="5"
Width="133%" DataKeyNames="SurveyID" DataSourceID="SqlDataSource1" AutoGenerateColumns="False"
>
<Columns>
<asp:BoundField DataField="SurveyID" HeaderText="Survey ID" ReadOnly="True"
.........
my onrowCommand code
public void stop_survey(object sender, GridViewCommandEventArgs e)
{
SqlConnection con;
string sqlcom;
SqlCommand cmd;
//is it because of this code below? as if i comment from this code onwards, the paging works.
GridViewRow row = (GridViewRow)((Button)e.CommandSource).NamingContainer;
Button btn = (Button)GridView1.Rows[row.RowIndex].FindControl("btnStop");
...............
Rebind your gridview in the PageIndexChanging event of the gridview control