binding gridview from other form

so confused

  • (2 Pages)
  • +
  • 1
  • 2

15 Replies - 2703 Views - Last Post: 24 May 2009 - 06:42 AM Rate Topic: -----

#1 izzahaf  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 112
  • Joined: 12-March 09

binding gridview from other form

Posted 18 May 2009 - 11:38 PM

hi hi,

i want to bind the grid view from other form. how should i do? help me

this my code:
			DataForm dataLoaded = new DataForm();
			foreach (SeriesVariable sv in DataInGrid)
			{
				this.dbase.Connect("select fact......."");
				try
				{
					
					while (this.dbase.variablereader.Read())
					{
						DataGridViewColumn column = new DataGridViewColumn();
						column.DataPropertyName = this.dbase.variablereader.GetString(0);
						column.HeaderText = sv.VariableDescription + "-" + sv.VariableName;
						column.Width = 85;
						string values = dbase.variablereader.GetString(0);
						sv.SeriesValues.Add(Double.Parse(values.ToString()));

						dataLoaded.grdVariable.Columns.Add(column);
						dataLoaded.grdVariable.DataSource = this.dbase.variablereader;
					}
				}
				catch
				{
					MessageBox.Show("error on getting values");
				}

				finally
				{
					this.dbase.variablereader.Close();
				}
			 
			} 



when i run it, data that i hope on datagridview is nothin

help.......it's urgen

thx b4

Is This A Good Question/Topic? 0
  • +

Replies To: binding gridview from other form

#2 newProgram  Icon User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 160
  • Joined: 28-October 08

Re: binding gridview from other form

Posted 19 May 2009 - 12:49 AM

View Postizzahaf, on 18 May, 2009 - 10:38 PM, said:

hi hi,

i want to bind the grid view from other form. how should i do? help me

this my code:
			DataForm dataLoaded = new DataForm();
			foreach (SeriesVariable sv in DataInGrid)
			{
				this.dbase.Connect("select fact......."");
				try
				{
					
					while (this.dbase.variablereader.Read())
					{
						DataGridViewColumn column = new DataGridViewColumn();
						column.DataPropertyName = this.dbase.variablereader.GetString(0);
						column.HeaderText = sv.VariableDescription + "-" + sv.VariableName;
						column.Width = 85;
						string values = dbase.variablereader.GetString(0);
						sv.SeriesValues.Add(Double.Parse(values.ToString()));

						dataLoaded.grdVariable.Columns.Add(column);
						dataLoaded.grdVariable.DataSource = this.dbase.variablereader;
					}
				}
				catch
				{
					MessageBox.Show("error on getting values");
				}

				finally
				{
					this.dbase.variablereader.Close();
				}
			 
			} 



when i run it, data that i hope on datagridview is nothin

help.......it's urgen

thx b4

past the dataset to the form where your grid view is located.
Was This Post Helpful? 0
  • +
  • -

#3 izzahaf  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 112
  • Joined: 12-March 09

Re: binding gridview from other form

Posted 19 May 2009 - 12:52 AM

View PostnewProgram, on 18 May, 2009 - 11:49 PM, said:

past the dataset to the form where your grid view is located.



i'm sorry i don't understand what u mean? can u axplain me?
thx
Was This Post Helpful? 0
  • +
  • -

#4 newProgram  Icon User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 160
  • Joined: 28-October 08

Re: binding gridview from other form

Posted 19 May 2009 - 01:04 AM

View Postizzahaf, on 18 May, 2009 - 11:52 PM, said:

View PostnewProgram, on 18 May, 2009 - 11:49 PM, said:

past the dataset to the form where your grid view is located.



i'm sorry i don't understand what u mean? can u axplain me?
thx

Quote

Where will you get the data for the gridview?

Was This Post Helpful? 0
  • +
  • -

#5 noorahmad  Icon User is offline

  • Untitled
  • member icon

Reputation: 209
  • View blog
  • Posts: 2,290
  • Joined: 12-March 09

Re: binding gridview from other form

Posted 19 May 2009 - 01:19 AM

what are you using as you database
Was This Post Helpful? 0
  • +
  • -

#6 newProgram  Icon User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 160
  • Joined: 28-October 08

Re: binding gridview from other form

Posted 19 May 2009 - 01:31 AM

View PostnewProgram, on 19 May, 2009 - 12:04 AM, said:

View Postizzahaf, on 18 May, 2009 - 11:52 PM, said:

View PostnewProgram, on 18 May, 2009 - 11:49 PM, said:

past the dataset to the form where your grid view is located.



i'm sorry i don't understand what u mean? can u axplain me?
thx

Quote

Where will you get the data for the gridview?

you will bind your grid view thru the dataset that you made. If you create your dataset on form1 and you will bind the grid view on form2. In order to do that you will past the dataset from form1 to form2
Was This Post Helpful? 0
  • +
  • -

#7 noorahmad  Icon User is offline

  • Untitled
  • member icon

Reputation: 209
  • View blog
  • Posts: 2,290
  • Joined: 12-March 09

Re: binding gridview from other form

Posted 19 May 2009 - 01:43 AM

View PostnewProgram, on 19 May, 2009 - 12:01 PM, said:

you will bind your grid view thru the dataset that you made. If you create your dataset on form1 and you will bind the grid view on form2. In order to do that you will past the dataset from form1 to form2


or you can create a global Dataset to access it in other forms
Was This Post Helpful? 0
  • +
  • -

#8 izzahaf  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 112
  • Joined: 12-March 09

Re: binding gridview from other form

Posted 19 May 2009 - 06:37 AM

yup, i will pass datareader from form1 to form2 that was opened. the datagridview in form2 was changed to public but it don't work.
i will make datagridview column on datagridview in form2.

how should i do?
please help me.... :(

thx
Was This Post Helpful? 0
  • +
  • -

#9 izzahaf  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 112
  • Joined: 12-March 09

Re: binding gridview from other form

Posted 19 May 2009 - 03:49 PM

still having issue :(
Was This Post Helpful? 0
  • +
  • -

#10 newProgram  Icon User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 160
  • Joined: 28-October 08

Re: binding gridview from other form

Posted 19 May 2009 - 06:38 PM

View Postizzahaf, on 19 May, 2009 - 02:49 PM, said:

still having issue :(

After you pass the DataSet, bind your grid view like this:
GridView1.DataSource = <your_dataset>;
GridView1.DataBind();


Was This Post Helpful? 0
  • +
  • -

#11 izzahaf  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 112
  • Joined: 12-March 09

Re: binding gridview from other form

Posted 20 May 2009 - 08:15 AM

doesn't work.... :(

what's wrong??? :ph34r:
DataForm dataLoaded = new DataForm();
			DataTable tableToGrid = new DataTable();
			
			if (DataInGrid != null)
			{
				foreach (SeriesVariable sv in DataInGrid)
				{
					this.dbase.Connect("select fact......................."");
					DataColumn dataColumn = new DataColumn(sv.VariableDescription + "-" + sv.VariableName, typeof(double));
				   
					tableToGrid.Columns.Add(dataColumn);
					try
					{
						while (this.dbase.variablereader.Read())
						{
							
							string values = dbase.variablereader.GetString(0);
							sv.SeriesValues.Add(Double.Parse(values.ToString()));
							DataRow row = tableToGrid.NewRow();
							row[dataColumn] = values;
							tableToGrid.Rows.Add(row);
						}
					  
						

					}
					catch
					{
						MessageBox.Show("error on getting values");
					}

					finally
					{
						this.dbase.variablereader.Close();
					}
				 }
				dataLoaded.grdVariable.DataSource = tableToGrid;
				dataLoaded.Show();



help...help
Was This Post Helpful? 0
  • +
  • -

#12 papuccino1  Icon User is offline

  • His name was Robert Paulson.
  • member icon

Reputation: 63
  • View blog
  • Posts: 1,121
  • Joined: 02-March 08

Re: binding gridview from other form

Posted 20 May 2009 - 08:33 AM

I wish I could help bro. But I'm new to DataBinding.
Was This Post Helpful? 0
  • +
  • -

#13 izzahaf  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 112
  • Joined: 12-March 09

Re: binding gridview from other form

Posted 20 May 2009 - 04:19 PM

View Postpapuccino1, on 20 May, 2009 - 07:33 AM, said:

I wish I could help bro. But I'm new to DataBinding.


ya, never mind.


anyone can help me? :D
Was This Post Helpful? 0
  • +
  • -

#14 izzahaf  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 112
  • Joined: 12-March 09

Re: binding gridview from other form

Posted 21 May 2009 - 05:38 AM

shifted.... :D
still need a help.
Was This Post Helpful? 0
  • +
  • -

#15 izzahaf  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 112
  • Joined: 12-March 09

Re: binding gridview from other form

Posted 22 May 2009 - 07:52 AM

shifted.... again :D

still having issue
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2