Steve
Steve

Reputation: 3080

Horizontal Table design using Gridview, Repeater etc

Im looking to build a nice form which a supplier can quote prices on. SO the form will have Labels down the left hand side and then their would be a Column per requested Product/Quantity from the buyer. So it would have n number of columns.

Because of the way html tables are coded you need to build a row at a time. (I want to keep this as one table so its neat HTML)

Before I go ahead and create Repeater for each row of information the user needs to enter. Is their a way to be able to create a sorta grid view but instead of each records you pass it going to create a new row. It would create a new column and you could define the first column as the header column?

My table sort design is (txtb stands for textbox and lbl stands for label which is updated as values are entered)

Quantity 500 1000 2000

Delivery Cost txtb txtb txtb

Pricing txtb txtb txtb

Total Cost lbl lbl lbl

Exchange Rate txtb txtb txtb

Thanks

Upvotes: 0

Views: 1032

Answers (2)

Saeed Neamati
Saeed Neamati

Reputation: 35822

May I suggest using ul tags (unordered lists). They suite your requirement much more easier, as I've done it in a similar situation. Table will cause you many pains down the way.

Upvotes: 1

Mantorok
Mantorok

Reputation: 5266

Are these labels/controls fixed? Because if so you don't need to write a control to render them, you could just code the HTML straight in.

If you are generating the form from a data-source then there are a number of ways to do this in Web Forms, however for simplicity I would stick to a Repeater, it's the cleanest way to achieve this, particularly if you don't need the bells and whistles in the other controls.

<asp:Repeater runat="server" ID="rptFields">
<HeaderTemplate>
   <table>
</HeaderTemplate>
<ItemTemplate>
   <tr>
      <td><%#Eval("Label") %></td>
      <td><asp:Textbox runat="server"/></td>
   </tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>

However bear in mind if you generate these controls you will not be able to access them from he code-behind directly, you would have to access them through the form fields or the repeater.

Upvotes: 0

Related Questions