hi .. i want to use repeater as a 5x5 grid .. i have a record of 25 five column i want to display 5 in row and i need 5 column like can anyone tell me what should i do for
thanks in advance
hi .. i want to use repeater as a 5x5 grid .. i have a record of 25 five column i want to display 5 in row and i need 5 column like can anyone tell me what should i do for
thanks in advance
Assuming you mean an html table when you say "grid", simply place the tags outside the Repeater and the table rows inside:
<table>
<asp:Repeater ID="foo" DataSource="bla" runat="server">
<ItemTemplate>
<tr>
<td>Col 1</td>
<td>Col 2</td>
...
</tr>
</ItemTemplate>
</asp:Repeater>
</table>
thnx every one but if i have only one column record let say top25 record of employername and then if i want to display 5 record in row and 5 column like that so what should i do??
Is the repeater a requirement? If not use the DataList instead. It does exactly what you want: It allows you to crate Columns. It manages when to create new Columns vs Rows.
See this description. http://quickstarts.asp.net/QuickStartv20/aspnet/doc/ctrlref/data/datalist.aspx
I agree with @brian chandley that the DataList control is an easy to use control. If you're prefer to use a casual table though, you could try the following - in the xml side:
<asp:Table ID="myTable" runat="server">
</asp:Table>
In some event in the code behind (presumably load or some click event)
List<string> myEmployerList = yourFunctionToPopulateList();
TableRow row = null;
for(int j=0;j<myEmployerList.Count;j++)
{
if (j % 5 == 0) row = new TableRow();
TableCell cell = new TableCell();
cell.Text = myEmployerList[j];
row.Cells.Add(cell);
if (j % 5 == 4) myTable.Rows.Add(row);
}
if(j % 5 != 4) myTable.Rows.Add(row); // Catch uneven rows at the end