Click here to Skip to main content
15,883,886 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
I developed a gridview in an asp.net page.

the same gridview is binding with data from DB

while running in LocalHost,its refreshing correctly,but when uploading to server,after that its not refreshing.

Ex:

Gridview consists of a delete and edit button,when delete button is pressed,the entire row will delete and grid will refresh.its working fine in localhost,but not in server...

Could you help me?

Code following

C#
public void gridfill()
   {
       try
       {
           reader = obj.SelCommand("select ta.id as Code,ta.activity as Activity,tc.client_name as Client,td.department as Department,billable as Billable from tbl_activity ta,tbl_dept td,tbl_client tc where ta.department=td.id and ta.client=tc.id order by cast(ta.id as int)");
           using (reader)
           {
               DataTable dt = new DataTable();
               dt.Load(reader);
               grdActivity.DataSource = dt;
               grdActivity.DataBind();
               if (grdActivity.Rows.Count >= 1)
               {
                   grdActivity.HeaderRow.Cells[2].Visible = false;
                   foreach (GridViewRow gvr in grdActivity.Rows)
                   {
                       gvr.Cells[2].Visible = false;

                   }
               }
           }
           reader.Close();
       }
       catch (Exception ex)
       {
           Response.Write("Error in Page:" + ex.Message);
       }
   }
protected void grdActivity_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        try
        {
            if (e.CommandName == "DELETE")
            {
                int index = Convert.ToInt32(e.CommandArgument);
                string activity_id = grdActivity.Rows[index].Cells[2].Text;
                obj.IDUCommand("Delete tbl_activity where id='" + activity_id + "'");
                gridfill();
                lblMessage.Text = "Successfully Deleted";

            }
catch (Exception ex)
        {
            Response.Write("Error in Page:" + ex.Message);
        }
}


OP Solved himself - his reply from comment

Thank you all for participating.. i had used image for delete button,so that it seems working sometimes and not getting updated,now i changed it to LINK,so now its working perfectly .....thanks
Posted
Updated 1-Mar-11 6:41am
v3
Comments
pankajupadhyay29 28-Feb-11 0:24am    
have you handled events properly?
is there any change in markup in server and local machine?
check for these if still u have problem then provide some code, Markup of grid
Sunasara Imdadhusen 28-Feb-11 0:29am    
Is there any error?
coolestCoder 28-Feb-11 0:42am    
can you post sample code, about which events are being handled ?
Sandeep Mewara 28-Feb-11 11:02am    
There must be some issue in your code. Share it.
Sandeep Mewara 28-Feb-11 11:03am    
BTW, don't post that as an answer. Update your question using 'Improve Question' link.

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