Click here to Skip to main content
15,881,139 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
Hi friends,

I am trying to make a user control (.ascx) to hold data from excelsheet. but not succeed. here is sample of my code. please help me.

C#
try
        {
            if (!IsPostBack)
            {                
                  _Connector.FillDataTable(ref ExcelTable, ExcelFileName, ExcelSheet.GetValue(0).ToString());

                  
                  for (int i = 0; i <= ExcelTable.Rows.Count - 1; i++)
                  {
                      Image img = new Image();
                      img.ID = "Teacher" + i;
                      img.ImageUrl = (Server.MapPath(ExcelTable.Rows[i][7].ToString()));
                      img.Width = Unit.Pixel(100);
                      img.Height = Unit.Pixel(120);

                      Label name = new Label();
                      name.ID = "name" + i;
                      name.Text = ExcelTable.Rows[i][1].ToString();

                      Label father = new Label();
                      father.ID = "father" + i;
                      father.Text = ExcelTable.Rows[i][2].ToString();

                      Label Dob = new Label();
                      Dob.ID = "dob" + i;
                      Dob.Text = ExcelTable.Rows[i][3].ToString();

                      Label Acadamic = new Label();
                      Acadamic.ID = "academic" + i;
                      Acadamic.Text = ExcelTable.Rows[i][4].ToString();

                      Label comercial = new Label();
                      comercial.ID = "comercial" + i;
                      comercial.Text = ExcelTable.Rows[i][5].ToString();

                      Label experience = new Label();
                      experience.ID = "experience" + i;
                      experience.Text = ExcelTable.Rows[i][6].ToString();

                      this.Controls.Add(img);
                      this.Controls.Add(name);
                      this.Controls.Add(father);
                      this.Controls.Add(Dob);
                      this.Controls.Add(Acadamic);
                      this.Controls.Add(comercial);
                      this.Controls.Add(experience);
                  }
            }
        }

        catch { }
Posted
Updated 4-Mar-13 2:31am
v3
Comments
[no name] 4-Mar-13 9:23am    
"but not succeed" is not a helpful description of any kind of a problem.
ZurdoDev 4-Mar-13 14:25pm    
And what is the problem?

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