我已经使用下面的代码来加载和 SelectedIndexChanged 我的下拉列表。当我更改下拉列表的值时,它需要很长时间才能在我的页面标签中显示值。
Label1.Text = "Review Number:" + newReview + "(for preparing of Rev." + newRev;
protected void ddlProjectDocument_SelectedIndexChanged(object sender, EventArgs e)
{
_DataContext = new EDMSDataContext();
int newRev;
int newReview;
var x = ddlProjectDocument.SelectedValue;
var MaxRev = (from rev in _DataContext.tblTransmittalls
where rev.DocID.ToString() == ddlProjectDocument.SelectedValue
select rev.REV).Max();
if (MaxRev == null)
{
newRev = 0;
}
else
{
newRev = Convert.ToInt32(MaxRev) + 1;
}
var MaxReview = (from rev in _DataContext.tblFiles
where (rev.DocId.ToString() == ddlProjectDocument.SelectedValue) &&
(rev.Rev.ToString() == MaxRev)
select rev.Review).Max();
if (MaxReview == null)
{
newReview = 1;
}
else
{
newReview = Convert.ToInt32(MaxReview) + 1;
}
Label1.Text = "Review Number:" + newReview + "(for preparing of Rev." + newRev;
}
protected void ddlProjectDocument_Load(object sender, EventArgs e)
{
var query = from p in _DataContext.tblDocuments
orderby p.DocumentNo
select p;
int maxs = 0;
foreach (tblDocument v in query)
{
if (v.DocumentNo.Length > maxs)
maxs = v.DocumentNo.Length;
}
foreach (tblDocument vv in query)
{
string doctitle = vv.DocumentNo;
for (int i = vv.DocumentNo.Length; i < maxs ; i++)
{
doctitle += " ";
}
doctitle += " | ";
doctitle += vv.TITLE;
// Use HtmlDecode to correctly show the spaces
doctitle = HttpUtility.HtmlDecode(doctitle);
ddlProjectDocument.Items.Add(new ListItem(doctitle, vv.DocId.ToString()));
}
}