hi all
i want have a one form to always return columns[0] of selected row .
intermediate method is ReturnAllCode...s
i writed a public method ReturnAllCodes that I want always return Columns[0] Of selected Rows form form that i want ...
public int ReturnAllCodes(string WinTitle, string Query, string[] Fields, string RequestCode)
{
all_codes _all_code = new all_codes();
_all_code.Text = WinTitle;
_all_code.dgv_all.DataSource = SelectAllQuery(Query);
for (int i = 0; i < Fields.Length; i++)
{
_all_code.dgv_all.Columns[i].HeaderText = Fields[i];
}
_all_code.ShowDialog();
if (_all_code.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
}
return 0;
}
Notics : all_codes Is A From That Contain Only One Datagrid
I send my parameter to this method without problem ...
But For Get The Return Value I Have A problem that Is Cant Write Code For return Value ...
i means : how Do Return The Columns[0] of Selected Row in all_codes To Method ReturnAllCodest ???
this is a SelectAllQuery Method that No Problem (i Show it Only For Better Question)
public DataTable SelectAllQuery(String _query)
{
SqlConnection Mycon = new SqlConnection(strconnection);
SqlCommand myCommand = new SqlCommand();
myCommand.Connection = Mycon;
SqlDataAdapter myAdapter = new SqlDataAdapter();
DataTable dataTable = new DataTable();
dataTable = null;
DataSet ds = new DataSet();
try
{
myCommand.CommandText = _query;
if (Mycon.State != ConnectionState.Open)
{
Mycon.Open();
}
myCommand.ExecuteNonQuery();
myAdapter.SelectCommand = myCommand;
myAdapter.Fill(ds);
dataTable = ds.Tables[0];
if (Mycon.State != ConnectionState.Closed)
{
Mycon.Close();
}
}
catch (SqlException e)
{
return null;
}
finally
{
}
return dataTable;
}
Help Me Please
TNKs