Link to home
Start Free TrialLog in
Avatar of prdeshpande
prdeshpande

asked on

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.
ASKER CERTIFIED SOLUTION
Avatar of mayank_joshi
mayank_joshi
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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