I am facing problem when i try to deploy my website on iis 7.0 on test page.
i have to display some .mht files on iframe in gridview and error looks like below,
Server Error in '/' Application.
--------------------------------------------------------------------------------
Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index]
System.Collections.ArrayList.get_Item(Int32 index) +7485640
System.Web.UI.WebControls.GridViewRowCollection.ge t_Item(Int32 index) +13
_Default.retrivefile(Int32 j) +977
_Default.Page_Load(Object sender, EventArgs e) +598
System.Web.Util.CalliHelper.EventArgFunctionCaller (IntPtr fp, Object o, Object t, EventArgs e) +14
System.Web.Util.CalliEventHandlerDelegateProxy.Cal lback(Object sender, EventArgs e) +41
System.Web.UI.Control.OnLoad(EventArgs e) +91
System.Web.UI.Control.LoadRecursive() +74
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2603
and the code that i used in retrivefile(int ) function is. Please check it..
Expand|Select|Wrap|Line Numbers
- private void retrivefile(int j)
- {
- string medium = Request.QueryString["medium"];
- ViewState["Question_selected"] = j;
- string id = Session["uid"].ToString();
- _repSource = new List<string>();
- string url = Request.Url.ToString();
- string[] url_array = url.Split('/');
- string url1 = url_array[0] + "//" + url_array[2] + "/" + url_array[3];
- SqlConnection filecon = new SqlConnection("Data Source="shekhar";initial catalog=walking;uid=sa;pwd=shekhar;");
- filecon.Open();
- SqlDataAdapter cmd = new SqlDataAdapter("select Serial_No from Question_Copy where Session_ID='" + id + "'", filecon);
- DataSet ds = new DataSet();
- cmd.Fill(ds);
- int count = ds.Tables[0].Rows.Count;
- string[] names = new string[count];
- for (int i = 0; i < count; i++)
- {
- names[i] = ds.Tables[0].Rows[i]["Serial_No"].ToString();
- }
- ViewState["Quest_Srno"] = names.ToArray();
- j = selctquest(j);
- string file1 = names[j] + ".mht";
- if (medium == "English")
- {
- _repSource.Insert(0, url1 + "/StaticHTM/" + file1);
- QuestionView1.DataSource = _repSource.ToArray();
- QuestionView1.DataBind();
- ViewState["Quest_Srno"] = names.ToArray();
- }
- if (medium == "Hindi")
- {
- _repSource.Insert(0, url1 + "/New Folder/" + file1);
- QuestionView1.DataSource = _repSource.ToArray();
- QuestionView1.DataBind();
- ViewState["Quest_Srno"] = names.ToArray();
- }
- Label question_index = (Label)QuestionView1.Rows[0].FindControl("Label6");
- question_index.Text = "Question " + (j + 1) + " of " + 50;
- int total_quest = (int)ViewState["total_quest"];
- totalbutton(total_quest);
- Button2.Enabled = true;
- Button4.Enabled = true;
- Session["disable_submit"] = j;
- }
please help me out where i am doing mistake, waiting for your reply...........