0
votes

I have deployed a user control on sharepoint 2007 list Edit.aspx page. It is working fine on my test server but on production only the UI of the user control is loaded. No textbox or combo box on page load are getting filled. Please see the screen shot of default values of user control instead of the filled up data. Also find the code below which takes the ID from querystring and loads the required data on page load. I have used createdby value to check who is assigning the list item. If the user is accessing the data which is not created by him then its redirected to other page.Please guide me. What shall I do or check to make it work.

empty user control

public partial class Class1 : System.Web.UI.UserControl
{

    static string name, lname, Number;  

    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            string c1,c2,c3,c4,c5, Created;
            if (!Page.IsPostBack)
            {

                     EditID = Convert.ToInt32(Request.QueryString["ID"]);
                     name = SPContext.Current.Web.CurrentUser.Name;
                     lname = SPContext.Current.Web.CurrentUser.LoginName;

                SPSecurity.RunWithElevatedPrivileges(delegate()
             {
                 using (SPSite site = new SPSite("site name"))
                 {
                     using (SPWeb web = site.OpenWeb())
                     {
                         SPList list = web.Lists["list1"];
                         SPList UserSkill = web.Lists["list2"]; 
                         ItemForEdit = UserSkill.GetItemById(EditID);
                         c1 = ItemForEdit["col1"].ToString();
                         c2 = ItemForEdit["col2"].ToString();
                         c3 = ItemForEdit["col3"].ToString();
                         c4 = ItemForEdit["col4"].ToString();
                         c5 = ItemForEdit["col5"].ToString();
                         Created = ItemForEdit["Author"].ToString();
                         Number = ItemForEdit["col6"].ToString();
                         string[] extract;
                         extract = Created.Split('#');
                         if (name == extract[1])
                         {

                             WholeData = web.Lists["list1"].Items.GetDataTable(); 
                             Roles = WholeData.DefaultView.ToTable(true, "Title");
                             txtnumber.Text = Number;
                             ddlRole.DataSource = Roles;
                             ddlRole.DataTextField = "Title";
                             ddlRole.DataValueField = "Title";
                             ddlRole.DataBind();
                             ddlRole.SelectedValue = c1;

            //more code

            }
                         else
                         {
                             Response.Redirect("/IM/pages/Intrusion.aspx", false);
                         }
                     }
                 }
             });

            }
        }
        catch (Exception exc)
        {
            HttpContext.Current.Response.Write("<script>alert('Exception on page load: " + exc.Message + "')</script>");

        }
    }
}
1

1 Answers

0
votes

It looks at first cut to be a data issue.

To debug on your production box you can use a remote debugger, or you could add a call that checks if 0 items are returned and either product an error or log the result.