我在 textbox2 中有所有链接,但是当我单击转换按钮时,该链接应该出现在列表视图中。但我无法获得带有数据的列表视图。所以任何人都可以指导我
这是我的代码:
protected void btn_createlink_Click(object sender, EventArgs e)
{
var links = TextBox1.Text.Split(new string[] { "\n", "\r" }, StringSplitOptions.RemoveEmptyEntries);
// dt["Links"] = TextBox1.Text;
foreach (var link in links)
{
if (!IsLinkWorking(link))
{
//Here you can show the error. You don't specify how you want to show it.
TextBox2.ForeColor = System.Drawing.Color.Green;
TextBox2.Text += string.Format("{0}\nNot working\n\n ", link);
}
else
{
TextBox2.Text += string.Format("{0}\n working\n\n", link);
}
}
}
protected void Button2_Click(object sender,
EventArgs e)[convert button click event]
{
DataTable dt = new DataTable();
dt.Columns.Add("Links");
dt.Columns.Add("Status");
dt.Columns.Add("Error");
dt.AcceptChanges();
DataRow dr = dt.NewRow();
dr["Links"] = "";
dr["Status"] = "";
dr["Error"] = "";
dt.Rows.Add(dr);
dt.AcceptChanges();
myListView.DataSource = dt;
myListView.DataBind();
//var item = string.Format("[{0}, {1} ,{2}]", TextBox2.Text );
}
客户端:
<asp:ListView runat="server" ID="myListView">
<LayoutTemplate>
<table id="Table1" runat="server" border="1">
<tr id="Tr1" runat="server">
<th id="Th1" runat="server">Links</th>
<th id="Th2" runat="server">Status</th>
<th id="Th3" runat="server">Error</th>
</tr>
<tr runat="server" id="ItemPlaceholder">
</tr>
</table>
</LayoutTemplate>
<ItemTemplate>
<tr id="Tr2" runat="server">
<td id="Td1" runat="server"> Eval("Links")</td>
<td id="Td2" runat="server"> Eval("Status")></td>
<td id="Td3" runat="server"> Eval("Error")</td>
</tr>
</ItemTemplate>
</asp:ListView>