TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Amit Kumar
NA
140
41.1k
PageIndexChanging not working in Gridview
Aug 17 2013 8:01 AM
I have gridview
<asp:GridView ID="gvArticles" runat="server" DataKeyNames="ArticleID"
HeaderStyle-BackColor="#87cfe6" AutoGenerateColumns="false" ForeColor="White"
AllowPaging="true" AllowSorting="true" PageSize="3" Width="100%">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:ImageButton ID="imgDel" runat="server" CommandName="Delete" ImageUrl="~/Images/delete.jpg" Width="20px" Height="20px"/>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Title">
<ItemTemplate>
<asp:Label ID="lblTitle" runat="server" Text='<%#Eval("Title")%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Added Date">
<ItemTemplate>
<asp:Label ID="lblDate" runat="server" Text='<%#Eval("AddedDate") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
and this is the code for .cs file
public partial class DeleteArticles : System.Web.UI.Page
{
string str = ConfigurationManager.ConnectionStrings["connect"].ConnectionString;
SqlConnection con;
SqlCommand cmd;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
gvArt();
}
}
protected void gvArt()
{
con = new SqlConnection(str);
con.Open();
cmd = new SqlCommand("select * from Articles",con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
gvArticles.DataSource = ds;
gvArticles.DataBind();
con.Close();
}
protected void gvArticles_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
}
}
but when i try to change pageindex it doesn't change .
Reply
Answers (
3
)
how to check null values in dataset?
Unable to update in first click of button in gridview