Reputation: 216
I'm trying to add 3 radio buttons into each table cell that I create dynamically but they all position themselves outside of the cells and line up from the top most of the page:
I want the RadioButton created to position inside of the table cell. How do I do this? Any help will be greatly appreciated. Here's my code:
int count = 0;
int countRB = 0;
if (dataReader.HasRows)
{
testLabel1.Text = "dataReader.HasRows: " + dataReader.HasRows;
while (dataReader.Read())
{
count += 1;
htmlString.Append("<table border = '1'>");
htmlString.Append("<tr>");
htmlString.Append("<td>");
for (int i = countRB; i < countRB + 3; i++)
{
RadioButton rb = new RadioButton();
// Set the label's Text and ID properties.
rb.Text = "RadioButton" + (i+1).ToString();
rb.ID = "RadioButton" + (i + 1).ToString();
test_populatePlaceHolder.Controls.Add(rb);
// Add a spacer in the form of an HTML <br /> element.
test_populatePlaceHolder.Controls.Add(new LiteralControl("<br />"));
}
countRB = count * 3;
htmlString.Append(dataReader["dateTime"] + "<br />" + dataReader["statistics"]");
htmlString.Append("</td>");
htmlString.Append("</tr>");
htmlString.Append("</table>");
htmlString.Append("<br />");
}
test_populatePlaceHolder.Controls.Add(new Literal { Text = htmlString.ToString() });
dataReader.Close();
dataReader.Dispose();
}
}
}
}
Upvotes: 0
Views: 170
Reputation: 2653
Why not simply add radio button like:
<span><input type="radio" id="rd1" />SOMTEXT </span>
So in your code:
for (int i = countRB; i < countRB + 3; i++)
{
string tmptxt="<span><input type=\"radio\" id=\"RadioButton" + (i+1).ToString()\" />"RadioButton" + (i+1).ToString()</span>";
htmlString.Append(tmptxt)
}
Upvotes: 1