尝试从数据集中填充网站(网络表单)文本框
我无法将数据集放入名称为 PrefixDescription 的 Web 表单文本框中。我尝试将行转换为字符串,然后尝试将字符串放入文本框中。但是,文本框中没有显示任何内容。 DataSet 确实有数据。我尝试了数据绑定和数据绑定,但它们也不起作用。
private DirectoryEntry testAD = new DirectoryEntry();
private DataTable DT = new DataTable();
protected void Button2_Click(object sender, EventArgs e)
{
DirectorySearcher search = new DirectorySearcher(testAD);
SearchResultCollection myResults = search.FindAll();
search.PropertiesToLoad.Add("name");
DT.Columns.Add("name");
DT.Columns.Add();
foreach (SearchResult SR in myResults)
{
DataRow dr = DT.NewRow();
DirectoryEntry DE = SR.GetDirectoryEntry();
dr["name"] = DE.Properties["name"].Value;
DT.Rows.Add(dr);
DT.AcceptChanges();
PrefixDescription.Text = Convert.ToString(dr["name"]);
DE.Close();
}
}
I'm having trouble getting the DataSet into a webform textbox with the name PrefixDescription. I tried to convert the row into a string, and I then tried to put the string into the textbox. However, nothing appears in the textbox. The DataSet does have data. I tried databinding and databind, but those don't work either.
private DirectoryEntry testAD = new DirectoryEntry();
private DataTable DT = new DataTable();
protected void Button2_Click(object sender, EventArgs e)
{
DirectorySearcher search = new DirectorySearcher(testAD);
SearchResultCollection myResults = search.FindAll();
search.PropertiesToLoad.Add("name");
DT.Columns.Add("name");
DT.Columns.Add();
foreach (SearchResult SR in myResults)
{
DataRow dr = DT.NewRow();
DirectoryEntry DE = SR.GetDirectoryEntry();
dr["name"] = DE.Properties["name"].Value;
DT.Rows.Add(dr);
DT.AcceptChanges();
PrefixDescription.Text = Convert.ToString(dr["name"]);
DE.Close();
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
更好的是,使用
StringBuilder
,像这样..Better yet, use a
StringBuilder
, something like this..