Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Datagrid .net 1.1 Trying to store datagrid cell content in a string...

$
0
0
I am using .net 1.1. I am displaying the content of a table in a datagrid. My task is -> when i select any row in the datagrid it should load the select row content in the form.



public void DispalyCustomer(string CustomerName)
		{
			string DbConn = ConfigurationSettings.AppSettings["DbConn"];
			SqlConnection objConnection = new SqlConnection(DbConn);
			objConnection.Open();
			//Fire the command object

			SqlCommand objCommand = new SqlCommand("select * from Customertable where Customername = '"+ CustomerName +"'",objConnection);
			DataSet objDataset = new DataSet();
			SqlDataAdapter objAdapter = new SqlDataAdapter(objCommand);
			objAdapter.Fill(objDataset);

			//Display selected content on the screen
			string strcustomername = objDataset.Tables[0].Rows[0][0].ToString();
			string strcoyntrtname = objDataset.Tables[0].Rows[0][1].ToString();
			string strgender = objDataset.Tables[0].Rows[0][2].ToString();
			string strhobbies = objDataset.Tables[0].Rows[0][3].ToString();
			bool strstatus = Convert.ToBoolean(objDataset.Tables[0].Rows[0][4]);
			
			//Close the connection
			objConnection.Close();
		}

		private void dtgcustomer_Click(object sender, System.EventArgs e)
		{
			string strSelectedCustomer = dtgcustomer.CurrentCell.RowNumber.ToString();
			DispalyCustomer(strSelectedCustomer);
		}




i am trying to store the datagrid cell data into the string strSelectedCustomer and pass it to displaycustomer.

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>