on btnGetSubjects_Clik Event The Following Code Runs
Retrieve GSubj = new Retrieve();
DataSet DS = new DataSet();
DS = GSubj.GetSubjects(SclID, ClassID);
if (DS != null)
{
if (DS.Tables[0].Rows.Count > 0)
{
Table CreatTable = new Table();
CreatTable.ID = "tblDynamic";
//DS.Tables[0].Rows[rowNum][columnName].ToString();
for (int i = 0; i < DS.Tables[0].Rows.Count; i++)
{
TableRow row;
row = new TableRow();
row.Width = 250;
TableCell cell1 = new TableCell();
cell1.Width = 130;
Lbl = new Label();
Lbl.ID = DS.Tables[0].Rows[i][0].ToString();
Lbl.Text = DS.Tables[0].Rows[i][1].ToString();
cell1.Controls.Add(Lbl); // Creating Labels With Subject ID as Label ID and Subject Name as Label Text
row.Cells.Add(cell1);
TableCell cell2 = new TableCell();
txtbox = new TextBox();
txtbox.ID = "Sub" + DS.Tables[0].Rows[i][0].ToString();
txtbox.Attributes.Add("runat", "Server");
cell2.Controls.Add(txtbox); // Creating Textbox With Subject ID as Textbox ID
row.Cells.Add(cell2);
CreatTable.Rows.Add(row);
}
TablePlaceHolder.Controls.Add(CreatTable);
}
}
After Creating I am Trying to get the filled values
protected void btnSubmit_Click(object sender, EventArgs e)
{
Hashtable Subjects = new Hashtable();
foreach (Control ctrl in TablePlaceHolder.Controls)
{
if (ctrl is TextBox)
{
Subjects.Add(((TextBox)ctrl).ID, ((TextBox)ctrl).Text); // Filling Subject Code and marks to the Hash Table
}
}
}
but the place holder is null and its not showing any values
Code in aspx Page
<asp:PlaceHolder ID="TablePlaceHolder" runat="server" />
<br />
<asp:Button ID="btnSubmit" Text="Submit" runat="server" OnClick="btnSubmit_Click" />
please suggest me
Advance Thank you...