Click here to Skip to main content
15,894,630 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Following is my code where I create a table control which has multiple control like textbox etc... how to retrieve values entered by the user.

C#
protected void Page_Load(object sender, EventArgs e)
        {
            string DesignFilePath = Request.QueryString["ReportName"].ToString();
            ReportFields dsReportFieldList = new ReportFields();
            dsReportFieldList.ReadXml(DesignFilePath);

            int TotalRows = 0;
            int TotalColumn = 0;
            foreach(ReportFields.tbl_ReportFieldsRow  rf in dsReportFieldList.tbl_ReportFields)
            {
                TotalRows = Convert.ToInt32(rf.TotalRow) ;
                TotalColumn = Convert.ToInt32(rf.TotalColm);
                break;
            }

            Table ds = new Table();
            ds.ID="table1";
            ds.ViewStateMode = System.Web.UI.ViewStateMode.Enabled;
            ds.BorderStyle = BorderStyle.Solid;
            ds.BorderWidth = 1;
            ds.BorderColor = System.Drawing.ColorTranslator.FromHtml("#003366");
            ds.Width = 500;
            for (int idx = 0; idx < TotalRows; idx++)
            {
                TableRow tr = new TableRow();
                for (int idx1 = 0; idx1 < TotalColumn; idx1++)
                {
                    TableCell tc = new TableCell();
                    tc.Text = idx.ToString() + "," + idx1.ToString();
                    tr.Cells.Add(tc);
                }
                ds.Rows.Add(tr);
            }

            foreach (ReportFields.tbl_ReportFieldsRow rf in dsReportFieldList.tbl_ReportFields)
            {
                string[] Poss = rf.CellPosition.ToString().Split(',');
                ds.Rows[Convert.ToInt32(Poss[0])].Cells[Convert.ToInt32(Poss[1])].Controls.Add(CreateControlString(rf.sID,rf.sSize,"lable",rf.sCaption));
                ds.Rows[Convert.ToInt32(Poss[0])].Cells[Convert.ToInt32(Poss[1])].Controls.Add(CreateControlString(rf.sID, rf.sSize, rf.sControlType,""));
            }

            //FindControl("ContentPlaceHolder1").Controls.Add(ds);
            ContentPlaceHolder ch = new ContentPlaceHolder();
            ch = (ContentPlaceHolder)Page.Master.FindControl("ContentPlaceHolder1");
           
            ch.Controls.Add(ds);

            

            //ViewState.Add("stTable", ds);

        }
Posted
Updated 5-Jun-12 22:09pm
v2

each control have a client ID it means the ID of server control when rendered on client side!
give to your control a unique ID: control.ID = "rpt";
change ClientIDMode to static, it make ID as same as befor rendering page!
now you can access to your server control with client script with this value!
whit client scripting you can save value into cookies, hidden field, and then access from your code to this values!
 
Share this answer
 
Use java script to get the values and keep them in a hidden fields. In the end retrieved them in code behind.
 
Share this answer
 

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