我正在尝试将项目 ID 从查询字符串传递给 ddb_projectList 以使项目被选中并填充 GridView 但我的问题是当页面加载时它选择了第一个附加项目。注意选择的值仍然 -1
谁能帮忙解决这个问题
代码:
public partial class TasksInProjects : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//get loged in user id UserID from MembershipUser
MembershipUser memberUser = Membership.GetUser();
string StrUserID = memberUser.ProviderUserKey.ToString();
Guid userID = Guid.Parse(StrUserID);
hf_userID.Value = userID.ToString();
if (Request.QueryString["projectID"] == null)
{
//ddl_projects.SelectedValue = Request.QueryString["projectID"];
if (ddl_projects.SelectedValue != "-1")
{
Guid projectID = Guid.Parse(ddl_projects.SelectedValue);
gv_TaskListForUser.DataSource = Task.GetTasksInProjectForUser(userID, projectID);
gv_TaskListForUser.DataBind();
}
}
else
{
//ddl_projects.Visible = false;
//Guid projectID = Guid.Parse(Request.QueryString["projectID"]);
//gv_TaskListForUser.DataSource = Task.GetTasksInProjectForUser(userID, projectID);
//gv_TaskListForUser.DataBind();
ddl_projects.SelectedItem.Value = Request.QueryString["projectID"];
Guid projectID = Guid.Parse(ddl_projects.SelectedItem.Value.ToString());
gv_TaskListForUser.DataSource = Task.GetTasksInProjectForUser(userID, projectID);
gv_TaskListForUser.DataBind();
}
}
}