B
BrassicaNigra
I have a datagrid that has a dropdownlist in each row. When a user changes
one of these drop down values, the autopostback allows me to handle the event
using the OnSelectedIndexChanged event for the drop down.
This works fine, but I cannot find a way to retrieve which row the drop down
was changed in. The function is passed Sender and EventArgs, but neither of
them seem to contain access to the row number where the drop down list was
changed. In some other functions that are passed similar arguments I can
access e.rows.... and get to row number, but for some reason this is not
available in the EventArgs for my function. I do not want to use the
EditItemTemplate on the gridview because that is overkill for what I am
trying to accomplish. How do i get the row number of the drop down that is
being changed?
Following is the code of the function;
protected void ProductionStatusDropDown_OnSelectedIndexChanged(object
sender, EventArgs e)
{
SqlConnection connStatus = new SqlConnection("Data
Source=.\\SQLEXPRESS;Database=AAPCB;Integrated Security=True;Connect
Timeout=30;User Instance=False");
SqlCommand scStatus = new SqlCommand("spUpdateProductionStatus",
connStatus);
SqlParameter paSalesOrderID =
scStatus.Parameters.Add("@SalesOrderID", SqlDbType.Int);
SqlParameter paReleaseID = scStatus.Parameters.Add("@ReleaseID",
SqlDbType.Int);
SqlParameter paWorkCenter = scStatus.Parameters.Add("@WorkCenter",
SqlDbType.NVarChar, 50);
SqlParameter paWorkCenterStatus =
scStatus.Parameters.Add("@WorkCenterStatus", SqlDbType.NVarChar, 50);
TableCell tcReleaseID = (TableCell)GridView1.Rows[0].Cells[9];
DropDownList ddlWorkCenter = (DropDownList)sender;
scStatus.CommandType = CommandType.StoredProcedure;
paSalesOrderID.Value = Request.QueryString["SalesOrderID"];
paReleaseID.Value = tcReleaseID.Text;
paWorkCenterStatus.Value = "Queued";
paWorkCenter.Value = ddlWorkCenter.SelectedValue;
connStatus.Open();
scStatus.ExecuteNonQuery();
connStatus.Close();
}
The line
TableCell tcReleaseID = (TableCell)GridView1.Rows[0].Cells[9];
has the row hardwired to '0'. This is where I would like to use a variable
that contains the row number of the line that had the drop down changed.
Let me know if you need additional clarification.
Thank you.
Dale Hoffman
one of these drop down values, the autopostback allows me to handle the event
using the OnSelectedIndexChanged event for the drop down.
This works fine, but I cannot find a way to retrieve which row the drop down
was changed in. The function is passed Sender and EventArgs, but neither of
them seem to contain access to the row number where the drop down list was
changed. In some other functions that are passed similar arguments I can
access e.rows.... and get to row number, but for some reason this is not
available in the EventArgs for my function. I do not want to use the
EditItemTemplate on the gridview because that is overkill for what I am
trying to accomplish. How do i get the row number of the drop down that is
being changed?
Following is the code of the function;
protected void ProductionStatusDropDown_OnSelectedIndexChanged(object
sender, EventArgs e)
{
SqlConnection connStatus = new SqlConnection("Data
Source=.\\SQLEXPRESS;Database=AAPCB;Integrated Security=True;Connect
Timeout=30;User Instance=False");
SqlCommand scStatus = new SqlCommand("spUpdateProductionStatus",
connStatus);
SqlParameter paSalesOrderID =
scStatus.Parameters.Add("@SalesOrderID", SqlDbType.Int);
SqlParameter paReleaseID = scStatus.Parameters.Add("@ReleaseID",
SqlDbType.Int);
SqlParameter paWorkCenter = scStatus.Parameters.Add("@WorkCenter",
SqlDbType.NVarChar, 50);
SqlParameter paWorkCenterStatus =
scStatus.Parameters.Add("@WorkCenterStatus", SqlDbType.NVarChar, 50);
TableCell tcReleaseID = (TableCell)GridView1.Rows[0].Cells[9];
DropDownList ddlWorkCenter = (DropDownList)sender;
scStatus.CommandType = CommandType.StoredProcedure;
paSalesOrderID.Value = Request.QueryString["SalesOrderID"];
paReleaseID.Value = tcReleaseID.Text;
paWorkCenterStatus.Value = "Queued";
paWorkCenter.Value = ddlWorkCenter.SelectedValue;
connStatus.Open();
scStatus.ExecuteNonQuery();
connStatus.Close();
}
The line
TableCell tcReleaseID = (TableCell)GridView1.Rows[0].Cells[9];
has the row hardwired to '0'. This is where I would like to use a variable
that contains the row number of the line that had the drop down changed.
Let me know if you need additional clarification.
Thank you.
Dale Hoffman