[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 584
  • Last Modified:

How to create tables in ASP.Net c#

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
introlux
Asked:
introlux
  • 3
  • 3
1 Solution
 
jpaulinoCommented:
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
 
introluxAuthor Commented:
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
 
MasoudghCommented:
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
introluxAuthor Commented:
thanks
0
 
jpaulinoCommented:
Well I have showed you the backcolor and I didn't had time to post back ...

0
 
introluxAuthor Commented:
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
 
jpaulinoCommented:
No problem ... you will give next time :)
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now