0
將2個單元格添加到asp:Table Table的解決方案。我從數據庫中提取表格的數據,並用字符串函數刪除逗號分隔的項目。將多個單元格添加到TableRow
protected void listView_Bids(object sender, ListViewItemEventArgs e)
{
if (e.Item.ItemType == ListViewItemType.DataItem)
{
TextBox TextBoxHighlights = (TextBox)e.Item.FindControl("TextBox2");
Table FindHighlightTable = (Table)e.Item.FindControl("bidHighlightTable");
if (TextBoxHighlights != null)
{
string benefits = (TextBoxHighlights.Text.ToString());
TableRow row = new TableRow();
int i = 0;
string[] words = benefits.Split(',');
foreach (string word in words)
{
if (i == 0 || i % 2 == 0)
{
row = new TableRow();
}
TableCell cell1 = new TableCell();
cell1.Text = word.ToString();
row.Cells.Add(cell1);
i++;
if (i % 2 == 0)
{
FindHighlightTable.Rows.Add(row);
}
}
}
}
}
這裏是我在我的ListView:
<asp:Table ID="bidHighlightTable" CssClass="table table-striped table-bordered bid-highlight-table" runat="server">
<asp:TableRow runat="server">
<asp:TableCell runat="server"></asp:TableCell>
<asp:TableCell runat="server"></asp:TableCell>
</asp:TableRow>
</asp:Table>
謝謝,我會研究它。我的一位朋友幫助我解決了這個問題,並且編輯了我的帖子以顯示解決方案。 – brandozz