Hello,
So I'm having a weird little issue.. I'm using a dropdown list in a ComponentArt Dialog (if you don't know what this is, it doesn't matter too much, just a popup menu) and within this dropdown list is a list of projects to select from.
PROBLEM SUMMARY: When I select an item from the dropdown list, and click the submit button, it registers a different value than the selected value from the dropdown list.
Now, when I submit this code, I want it to take the information from the popup (textbox info) and input it into the database with a projectid value of the DataValueField in the selected item from the dropdown list. This works great... the first time... if I open the popup on the first click (when visiting the site for one session) it submits everything perfectly when I click the submit button (this closes the popup, submits the info, and closes the popup) If I prompt the popup again, enter info, and hit submit, it closes, and then my error checking label tells me that it tried to take the DataValueField of the first item in the list, not the one that I selected. So somewhere I assume that it resets somehow.. I just don't understand why. Below is the function for the submit task button, as well as part of the buildgrid() function that manipulates the dropdown list.
Let me know if you need anything else.
Any ideas?
Thanks a lot in advance, been working on this for a few hours now..
csharp
OleDbConnection MyConnection = new OleDbConnection();
MyConnection = PLDBMgr.dbconnect.GetConn();
string percentComplete;
if (Int32.Parse(txtbTaskSlider.Text) < 10)
percentComplete = "0" + txtbTaskSlider.Text;
else
percentComplete = txtbTaskSlider.Text;
string userid = Session["s_curuserId"].ToString();
string associated_project = ddlProject.SelectedValue.ToString();
string name = txtbTaskName.Text;
string startdate = txtbTaskStartDate.Text;
string enddate = txtbTaskDueDate.Text;
string status = "0." + percentComplete;
string report = txtbTaskStatusReport.Text;
string affiliates = txtbTaskAffiliates.Text;
string InsertSql = "insert into <removed> (userid, projectid, taskName, startDate, endDate, status, statusReport, affiliates) values(" + userid + ", "
+ associated_project + ", '" + name + "', '" + startdate + "', '" + enddate + "', " + status + ", '" + report + "', '" + affiliates + "')";
lbltest.Text += ddlProject.SelectedItem.ToString() + ", " + ddlProject.SelectedValue.ToString()
+ ", " + ddlProject.SelectedIndex.ToString();
lblSql2.Text = InsertSql;
try
{
PLDBMgr.dbconnect.ExecNonQuery(InsertSql);
}
catch (Exception ex)
{
lblError.Text = ex.Message;
}
MyConnection.Close();
ddlProject.SelectedIndex = 0;
txtbTaskName.Text = "";
txtbTaskStartDate.Text = "";
txtbTaskDueDate.Text = "";
txtbTaskSlider.Text = "";
txtbTaskStatusReport.Text = "";
txtbTaskAffiliates.Text = "";
csharp
ddlProject.Items.Clear();
sql = "SELECT projectName, projectID from projects where userid = " + user;
//DataTable projectData = new DataTable();
DataSet projectData = new DataSet();
OleDbDataAdapter data = new OleDbDataAdapter(sql, srcDB);
data.Fill(projectData, "projects");
ddlProject.Items.Add("<-- Select Project -->");
ddlProject.DataSource = projectData.Tables[0];
ddlProject.DataTextField = projectData.Tables[0].Columns["projectName"].ColumnName.ToString();
ddlProject.DataValueField = projectData.Tables[0].Columns["projectid"].ColumnName.ToString();
ddlProject.DataBind();
This post has been edited by Zehuti: 7 Aug, 2008 - 11:56 AM