Solved

How to create tables in ASP.Net c#

Posted on 2008-06-12
7
572 Views
Last Modified: 2013-11-26
I am trying to create tables using the ASP.Net format but im having few problems. How do I create columns in the table, how do i shade the background colour of a cell etc...

Its not as simple as using HTML normal tag tables. Any help will be appreciated.

Thanks,

introlux
<asp:Table id="tbl_ProCom" runat="server"

    Caption="Project Commissioning Form"

    HorizontalAlign="Center"

    GridLines="Both"

    Width="192px">

        <asp:TableRow ID="tblProData" runat="server" HorizontalAlign="Left">

                <asp:TableCell ID="ProData1" runat="server" HorizontalAlign="Left" Wrap="False">

                    <b>Project Details</b>

                </asp:TableCell>

        </asp:TableRow>

        

        <asp:TableRow ID="tblProData2" runat="server" HorizontalAlign="Left">

                <asp:TableCell ID="TableCell1" runat="server" HorizontalAlign="Left" Wrap="False">

                <b>Project ID:</b>

                <b><asp:TextBox id="txtProID" runat="server" /></b>

                </asp:TableCell>

        </asp:TableRow>

        

        <asp:TableRow ID="TableRow2" runat="server" HorizontalAlign="Left">

                <asp:TableCell ID="TableCell2" runat="server" HorizontalAlign="Left" Wrap="False">

                <b>Project Name</b>

                <b><asp:TextBox id="txtProName" runat="server" /></b>

                </asp:TableCell>

                

        </asp:TableRow>

                <asp:TableRow ID="TableRow3" runat="server" HorizontalAlign="Left">

                <asp:TableCell ID="TableCell3" runat="server" HorizontalAlign="Left" Wrap="False">

                <b>ICD/IDF</b>

                <b><asp:TextBox id="txtICD_IDF" runat="server" /></b>

                </asp:TableCell>

        </asp:TableRow>

        

        <asp:TableRow ID="ProData2" runat="server" HorizontalAlign="Left">

                <asp:TableCell ID="TableCell4" runat="server" HorizontalAlign="Left" Wrap="False">

                <b>Project Type</b>

                <b><asp:TextBox id="TextBox1" runat="server" /></b>

                </asp:TableCell>

        </asp:TableRow>         

</asp:Table>

Open in new window

0
Comment
Question by:introlux
  • 3
  • 3
7 Comments
 
LVL 48

Expert Comment

by:jpaulino
ID: 21767439
You can do like this:

 <asp:TableRow TableSection="TableHeader" BackColor="Pink">
            <asp:TableCell Text="Header" ColumnSpan="3" />
  </asp:TableRow>

Check this MSDN example: http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.tablerow.tablesection.aspx
0
 

Author Comment

by:introlux
ID: 21767570
Great info!

The only thing im stuck about is how I will be changing text colour, expanding row width so that the background colour can be equal length going downwards.

And also, is it possible to put validation into text boxes that are in the table??? (i.e. you have to enter text in this field, wrong data entered etc..)
0
 
LVL 3

Accepted Solution

by:
Masoudgh earned 500 total points
ID: 21768275
Use "ForeColor" attribute to change text's color.
        <asp:TableRow ForeColor="#FF00FF" ID="tblProData" runat="server" HorizontalAlign="Left">
                <asp:TableCell ID="ProData1" runat="server" HorizontalAlign="Left" Wrap="False">
                    <b>Project Details</b>
                </asp:TableCell>
        </asp:TableRow>

for validating your controls, use "Validation Controls" in Toolbox. For example use "RegularExpressionValidator" or "RequiredFieldValidator".
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

Author Closing Comment

by:introlux
ID: 31466465
thanks
0
 
LVL 48

Expert Comment

by:jpaulino
ID: 21768638
Well I have showed you the backcolor and I didn't had time to post back ...

0
 

Author Comment

by:introlux
ID: 21768685
Thats true, how do i share the points?? I have only been a member of this forum for a few weeks. I will ammend this if possible. As you deserve at least half. sorry once again.
0
 
LVL 48

Expert Comment

by:jpaulino
ID: 21768748
No problem ... you will give next time :)
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Problem with SqlConnection 5 115
.NET Error 7 42
Separate a number and letter from a string 25 26
Saveas need to save a copy 16 11
Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now