Click here to Skip to main content
15,889,335 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, please help me out!

my code is

C#
protected void Page_Load(object sender, EventArgs e)
    {
        int Count1= GrvNewPORequests.Rows.Count;
        
        if (!IsPostBack)
        {
            txtPODate_CalendarExtender.StartDate = DateTime.Today;
            txtReqDate_CalendarExtender.StartDate = DateTime.Today;
            
            BindGridNewPOReq();
            int count = GrvNewPORequests.Rows.Count;
            // first time the count will show the no of rows and same will display on the page
        }
       // Second time Coiunt1 will show '0' !
    }



The same code is working fine where the master page is different!
Posted
Comments
prashantttt 12-Oct-13 2:55am    
How you are filling Grid?
Manzoor Ahmed P 12-Oct-13 3:58am    
Sorry i m late i was out for lunch...

this is how i m filling Grid

public void BindGridNewPOReq()
{
using (SqlConnection conn = new SqlConnection())
{
try
{
conn.ConnectionString = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
using (SqlCommand cmd = new SqlCommand())
{
DataTable dt = new DataTable();
string cmdText = "select * from PLNGPRItemDet where(type = 'Purchase Order' and POStatus = 'pending @ purchase') ORDER BY JobNo ASC ";
cmd.CommandText = cmdText;
cmd.Connection = conn;
SqlDataAdapter da = new SqlDataAdapter(cmd);
conn.Open();
da.Fill(dt);

GrvNewPORequests.DataSource = dt;
GrvNewPORequests.DataBind();
GrvNewPORequests.Columns[1].Visible = false;
conn.Close();
}
}
catch (Exception ex)
{

}
}
if (GrvNewPORequests.Rows.Count < 1)
{
lblNoNewReq.Visible = true;
panelTop.Visible = false;
}
}
prashantttt 12-Oct-13 4:34am    
Have u specified in Gridview tag EnableViewState="false"...?
Please check for it...
it can b one reason.....
Manzoor Ahmed P 17-Oct-13 0:52am    
Thanks Everybody!...
Sorry for late reply, actually i wa on holiday
The problem was My master page's EnableViewState property was false !
jaideepsinh 12-Oct-13 7:42am    
Your code is correct.So use break point for finding at which link you get error and tell us.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900