How to add label control or text control in Datatable?

Hi, I have created DataTable programmatically and added below columns:
---------------------------------------------------------------------------------------------
DataColumn dtc = new DataColumn("Site Title", Type.GetType("System.String"));
dt.Columns.Add(dtc);
dtc = new DataColumn("User Name", Type.GetType("System.String"));
dt.Columns.Add(dtc);
dtc = new DataColumn("Read", Type.GetType("System.String"));
dt.Columns.Add(dtc);
--------------------------------------------------------------------------------
And created label:
------------------------------------------------------------
Label lbl = new Label();
lbl.BackColor = Color.Blue;
lbl.Text = “textbox1.text”;
-------------------------------------------------------------
Now, how to add lable in DataTable so labale color and the text value of label should display.
Means, I want to add here:
dtr["Site Title"] = “label should come here with blue color”;  //DataRow dtr;

Kindly help.
LVL 1
prdeshpandeAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mayank_joshiCommented:
A Datatable is meant only for data.You can not add label control or textbox control to it.
But you can add their values using label.Text or TextBox.text
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mayank_joshiCommented:
You may use the asp "Table" server control for adding controls.
or you may use Datatable for adding each property of a control in a separate column.
0
Asim NazirCommented:
Hi,

What joshi is saying is correct. On HTML side perhaps this will help:
 
<table class="style1">
        <tr>
            <td>
                <asp:Label ID="Label1" runat="server" BackColor="#0066FF" Text="Label"></asp:Label>
            </td>
            <td>
                &nbsp;</td>
        </tr>
        <tr>
            <td>
                &nbsp;</td>
            <td>
                &nbsp;</td>
        </tr>
    </table>

Open in new window


Asim
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.