有没有办法知道事件的最后一个视图索引是ActiveViewChanged
什么?
protected void mltv_ActiveViewChanged(object sender, EventArgs e)
{
//Here i nedd to know what it was, because here it is already changed
}
检查财产mltv.ActiveViewIndex
。到了这里。
只需将 Load Event 用于用户控制并引用 ActiveViewIndex。它应该在更改之前具有 ActiveViewIndex。对于下面的示例,我只是使用上下文项作为支持,但如果您有一个可以使用的类级别变量:
protected void mltv_Load(object sender, EventArgs e)
{
//Add your property backing or class variable here
int pos = mltv.ActiveViewIndex;
if (pos == -1)
return;
Context.Items["mltv_ActiveViewIndexOnLoad"] = pos;
}
protected void mltv_ActiveViewChanged(object sender, EventArgs e)
{
//Retrieve property, private variable, here:
var lastViewIndex = -1;
if (Context.Items["mltv_ActiveViewIndexOnLoad"] != null)
{
lastViewIndex = (int)(Context.Items["mltv_ActiveViewIndexOnLoad"]);
}
}