Can any one help me to over come the following problem?
I am facing 2 problems while working with ASP.NET 3.5 GridView control viz., 1) Paging is displayed, but once clicked on page2, it goes but then it gets disabled (not able to click again and not able to move to page1 Clicking on page is not responding and it is remaining in page 2 only.
2) I have tried adding a new column of type Imagefield and tried, but now this field shows a text "Image" and not image itself.
I have the following code: .aspx page
Code in the aspx.cs file:
namespace diplaydata
{
public partial class displaytabledata : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
bind();
}
}
private DataTable getTable()
{
//OracleDataAdapter adap = new OracleDataAdapter("select t.id, t.author, t.description from smstestblob t", "Data Source=PROWESS;User ID=DBA_PST;Password=PST;");
OracleDataAdapter adap = new OracleDataAdapter("select t.id, t.author, t.description, t.photo from smstestblob t", "Data Source=PROWESS;User ID=DBA_PST;Password=PST;");
//DataSet set = new DataSet();
DataTable dt = new DataTable();
adap.Fill(dt);
Response.Write("Rows In Data Table " + dt.Rows.Count.ToString());
return dt;
}
protected void bind()
{
DataTable dr = getTable();
gv_displaydata.DataSource = dr;
gv_displaydata.DataBind();
gv_displaydata.Visible = true;
gv_displaydata.Font.Bold = true;
//gv_displaydata.AllowPaging;
}
protected void gv_displaydata_PageIndexChanged(object sender, EventArgs e)
{
gv_displaydata.PageIndex = gv_displaydata.PageIndex + 1;
bind();
}
/*protected void gv_displaydata_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
{
gv_displaydata.PageIndex = gv_displaydata.PageIndex + 1;
bind();
}
protected void gv_displaydata_SelectedIndexChanged(object sender, EventArgs e)
{
gv_displaydata.PageIndex = gv_displaydata.PageIndex + 1;
bind();
}*/
protected void gv_displaydata_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
gv_displaydata.PageIndex = gv_displaydata.PageIndex + 1;
bind();
}
}
}
Thanks in advance for your help again.
Regards
MokshasriPosted Dec 10, 2009, 7:18 AM
I could solve the first problem of paging myself. And I solved this as follows:
protected void gv_displaydata_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
int newPageIndex = e.NewPageIndex;
gv_displaydata.PageIndex = newPageIndex;
//gv_displaydata.PageIndex = gv_displaydata.PageIndex + 1;
bind();
}
And removed the following event:
protected void gv_displaydata_PageIndexChanged(object sender, EventArgs e)
{
gv_displaydata.PageIndex = gv_displaydata.PageIndex + 1;
bind();
}
However, still I am facing problem with the image not getting displayed.
Please, let me know where I am going wrong in the code because of which the Image is not getting displayed. From the back-end I have seen that image is there in the BLOB field of the table. And in asp.net the query is returning result. Except for the image field all other fields data is getting displayed in the GridView.
Appreciate any quick help.
Thanks,
Regards,
Moksha