Hi,
I am create one web application in which i have to create dyanamically panel and table,tr,td,labels and textboxes. but when i split the string and create tr but more tr created i want 4 tds in 1 tr but they create 4 tr dynamically..
how to solve this problem..
private void GetLevels(string InstituteId, Int64 AdmissionProcessId, Int64 StepId)
{
int Col1=0,Col2=0;
try
{
DataSet ds;
ds = BAdmi_AdmissionApplicationMetadata.GetLevels(InstituteId, AdmissionProcessId, StepId);
string PnlName, MetaFieldGroup_string;
int MetaFieldGroupSequence_Int;
if (ds.Tables[0].Rows.Count > 0)
tdMetaDataTitle.Visible = true;
else
tdMetaDataTitle.Visible = false;
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
MetaFieldGroupSequence_Int = Convert.ToInt16(ds.Tables[0].Rows[i]["MetaFieldGroupSequence"].ToString());
PnlName = "pnl_" + ds.Tables[0].Rows[i]["MetaFieldGroupSequence"].ToString();
Panel pnlLevel = new Panel();
pnlLevel.ID = PnlName;
pnlLevel.Attributes.Add("style", "overflow: auto; width: 100%; height: 100% HorizontalAlign=Left");
pnlLevel.GroupingText = ds.Tables[0].Rows[i]["MetaFieldGroup"].ToString();
MetaFieldGroup_string = ds.Tables[0].Rows[i]["MetaFieldGroup"].ToString();
pnlLevel.TabIndex = (short)(17 + i);
datapanel.Controls.Add(pnlLevel);
pnlLevel.CssClass = "PanelStyle";
Table tblFields = new Table();
tblFields.ID = "tbl_" + ds.Tables[0].Rows[i]["MetaFieldGroupSequence"].ToString();
tblFields.Attributes.Add("style", "Align:Left");
tblFields.BorderColor = Color.Black;
pnlLevel.Controls.Add(tblFields);
DataSet dsFields = new DataSet();
dsFields = BAdmi_AdmissionStudentApplication.GetApplicationMetaFiledName(InstituteId, Convert.ToInt64(ddlAdmissionProcessName.SelectedValue.ToString()), Convert.ToInt64(lblStepId_New.Text), MetaFieldGroup_string, MetaFieldGroupSequence_Int);
if (dsFields.Tables[0].Rows.Count > 0)
{
for (int j = 0; j < dsFields.Tables[0].Rows.Count; j++)
{
string FieldNameTotalValue = dsFields.Tables[0].Rows[0]["Meta_FieldName"].ToString();
string[] MetaFiled_Sub;
string[] MetaFiled_SubData;
MetaFiled_Sub = FieldNameTotalValue.Split(',');
string Metafiled_SubLength = MetaFiled_Sub.Count().ToString();
for (int k = 0; k < Convert.ToInt64(Metafiled_SubLength) - 1; k++)
{
MetaFiled_SubData = MetaFiled_Sub[k].Split('-');
TableRow tr = new TableRow();
tr.ID = "tr_" + ds.Tables[0].Rows[i]["MetaFieldGroupSequence"].ToString() + j.ToString();
tr.Attributes.Add("style", "Align:Left");
TableCell tc1 = new TableCell();
tc1.ID = "tclabel_" + MetaFiled_SubData[1];
//tc1.ID = "tclabel_" + dsFields.Tables[0].Rows[j]["Meta_FieldName"].ToString();
tc1.Attributes.Add("style", "Align:Left");
tc1.CssClass = "style5";
Label lblFieldName1 = new Label();
lblFieldName1.ID = "field_" + MetaFiled_SubData[1];
// lblFieldName1.ID = "field_" + dsFields.Tables[0].Rows[j]["Meta_FieldName"].ToString();
// lblFieldName1.Text = dsFields.Tables[0].Rows[j]["Meta_FieldName"].ToString();
lblFieldName1.Text = MetaFiled_SubData[1];
tc1.Controls.Add(lblFieldName1);
tr.Cells.Add(tc1);
Col1 = Col1 + 1;
TableCell tc2 = new TableCell();
tc2.ID = "tctxt_" + MetaFiled_SubData[1];
// tc2.ID = "tctxt_" + dsFields.Tables[0].Rows[j]["Meta_FieldName"].ToString();
tc2.Attributes.Add("style", "Align:Left");
TextBox txtField1 = new TextBox();
txtField1.ID = "txt_" + MetaFiled_SubData[1];
// txtField1.ID = "txt_" + dsFields.Tables[0].Rows[j]["Meta_FieldName"].ToString();
tc2.Attributes.Add("style", "Width:199px");
tc2.Controls.Add(txtField1);
tr.Cells.Add(tc2);
Col2 = Col2 + 1;
if (dsFields.Tables[0].Rows.Count >= j + 2)
{
TableCell tc3 = new TableCell();
tc3.ID = "tclabel_" + MetaFiled_SubData[1];
//tc3.ID = "tclabel_" + dsFields.Tables[0].Rows[j + 1]["Meta_FieldName"].ToString();
tc3.Attributes.Add("style", "Align:Left");
Label lblFieldName2 = new Label();
//lblFieldName2.ID = "field_" + dsFields.Tables[0].Rows[j + 1]["Meta_FieldName"].ToString();
//lblFieldName2.Text = dsFields.Tables[0].Rows[j + 1]["Meta_FieldName"].ToString();
lblFieldName2.ID = "field_" + MetaFiled_SubData[1];
lblFieldName2.Text = MetaFiled_SubData[1];
tc3.Controls.Add(lblFieldName2);
tc3.CssClass = "style5";
tr.Cells.Add(tc3);
TableCell tc4 = new TableCell();
tc4.ID = "tctxt_" + MetaFiled_SubData[1];
//tc4.ID = "tctxt_" + dsFields.Tables[0].Rows[j + 1]["Meta_FieldName"].ToString();
tc4.Attributes.Add("style", "Align:Left");
TextBox txtField2 = new TextBox();
//txtField2.ID = "txt_" + dsFields.Tables[0].Rows[j + 1]["Meta_FieldName"].ToString();
txtField2.ID = "txt_" + MetaFiled_SubData[1];
tc4.Controls.Add(txtField2);
tr.Cells.Add(tc4);
}
j = j+ 1;
tblFields.Rows.Add(tr);
}
}
}
}
}
catch (Exception)
{
}
}