Witam z problemem borykam się juz od kilku ładnych godzin pewnie dla większości z was to drobnostka ok przejdę do konkretów
mam gridview a w nim dropdownlisty chciałbym aby po uruchomieniu akcji poszedł upddate do sql'a wstawiający wartości z dropdownlist.
Nieestety jakbym się do tego nie zabierał to updateowana jest albo jest pierwsza defaultowa wartość albo null.
Oto Kod

using System;
using System.Data;
using System.Collections;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Specialized;
using System.Text;
using System.Data.SqlClient;
using System.Data.Sql;
using System.Data.SqlTypes;
using System.Web.Mail;
using System.Net;
using System.IO;

public partial class wnios_view : System.Web.UI.Page
{

private SqlConnection mySQLconnection;
private SqlConnection conn;
private SqlConnection objInsert;
string kom;

protected void Page_Load(object sender, EventArgs e)
{




mySQLconnection = new SqlConnection();

mySQLconnection.ConnectionString = "Data Source=****;Initial Catalog=dbextest;Persist Security Info=True;User ID=****;Password=****";

// SQL Command object to pass the SQL query for retrieving the data from tbl_orders table.
SqlCommand mySqlCommand = new SqlCommand("select * from wnioski_prnv where idjednorg='test'", mySQLconnection);

SqlDataAdapter mySqlAdapter = new SqlDataAdapter(mySqlCommand);

DataSet myDataSet = new DataSet();

mySqlAdapter.Fill(myDataSet);

// GridView Data Control Bound to the DataSet filled with data retrieved from tbl_orders.
dg.DataSource = myDataSet;

dg.DataBind();

if (!Page.IsPostBack)
{
Populate1();
}

}
public void Populate1()
{

mySQLconnection = new SqlConnection();

mySQLconnection.ConnectionString = "Data Source=VIVESRV4;Initial Catalog=dbextest;Persist Security Info=True;User ID=admin;Password=viveusr";
// Here new SQL query is pass to the SQL command object to get the data from tbl_order_status table.

SqlCommand mySqlCommand = new SqlCommand("select * from WNIOSKI_PRNV_STAT where id=1", mySQLconnection);

SqlDataAdapter mySqlAdapter = new SqlDataAdapter(mySqlCommand);

DataSet myDataSet = new DataSet();

mySqlAdapter.Fill(myDataSet);

// DropDownList Control Object Created to bind the data dynamically with each nested DropDownlist control placed inside the template column of the GridView Control.
DropDownList drdList;

// foreach loop is used to loop through each row of GridView Control.
foreach (GridViewRow grdRow in dg.Rows)
{
// Nested DropDownList Control reference is passed to the DrdList object. This will allow you access the properties of dropdownlist placed inside the GridView Template column.
drdList = (DropDownList)(dg.Rows[grdRow.RowIndex].Cells[5].FindControl("DropDownList1"));

// DataBinding of nested DropDownList Control for each row of GridView Control.
drdList.DataSource = myDataSet;
drdList.DataValueField = "status";
drdList.DataTextField = "status";
drdList.DataBind();
}

}
protected void aktual(object sender, EventArgs e)
{

// string variable to store the connection string
// defined in appsettings section of web.config file.
string connStr = ConfigurationManager.ConnectionStrings["dbextestConnectionString"].ConnectionString;

// object created for SqlConnection Class.
SqlConnection mySQLconnection = new SqlConnection(connStr);

// if condition that can be used to check the sql connection
// whether it is already open or not.
if (mySQLconnection.State == ConnectionState.Closed)
{
mySQLconnection.Open();
}

// Sql Command Object
SqlCommand mySqlCommand;

DropDownList drdList;

foreach (GridViewRow row in dg.Rows)
{
//Pętla po wszystkich rekordach Griudview

drdList = (DropDownList)(dg.Rows[row.RowIndex].Cells[5].FindControl("DropDownList1"));


mySqlCommand = new SqlCommand("update dbo.WNIOSKI_PRNV set data_akc= @data, akceptacja=@status, uwagi_odp='<p>' where ID_wniosku = @id", mySQLconnection);

mySqlCommand.Parameters.AddWithValue("@usrname", User.Identity.Name);



mySqlCommand.Parameters.AddWithValue("@data", DateTime.Now.ToString());

// SQL command input parameter to set the new value for order_status_id
mySqlCommand.Parameters.Add("@status", drdList.SelectedValue);

// SQL command input parameter as order_id whose corresponding value for order_status_id is to be set
mySqlCommand.Parameters.Add("@id", dg.DataKeys[row.RowIndex]["id_wniosku"]);

// Execute the SQL query to update the tbl_orders
mySqlCommand.ExecuteNonQuery();


}
// if condition that can be used to check the sql connection
// if it is open then close it.
if (mySQLconnection.State == ConnectionState.Open)
{
mySQLconnection.Close();
}

dg.DataBind();
}



public void Signout_Click(Object sender, EventArgs e)
{
FormsAuthentication.SignOut();
Response.Redirect(@"~\wnios_view.aspx");
}

}