Click here to Skip to main content
13,251,998 members (50,887 online)
Rate this:
Please Sign up or sign in to vote.
See more:[^]

i want to pass data from Nametextbox and commenttexbox when pressing the button to an gridview. how should i solve this? i also has this column in a list there i can store it, so i want to store it in the gridview and also in the list were i have the colums.
Posted 1-Feb-13 15:34pm
Krunal Rohit 2-Feb-13 1:48am
Show your code..
jibesh 2-Feb-13 4:02am
what type of UI Lib windows Form,Web pages or what?
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Hi,I think the firts you need to do, it's to save the values in the textbox name and comment, then use it to see in the datagridview the form to insert values in the datagridview is namedatagrid[indexcolumn,indexrow].value = valueyouwanttoshow

for example:

dataGridView[0,0].value = "Hello World";

Rate this: bad
Please Sign up or sign in to vote.

Solution 2

use datatable or list to store your values, then assign the values to the datasource of your gridview.
Kurac1 2-Feb-13 9:58am
i have done like this..
` DataRow rd;
DataTable MyTable = new DataTable();
protected void Button2_Click(object sender, EventArgs e)

rd["Name"] = TextBoxName.Text;
rd["Comment"] = TextBoxComments.Text;


GridView1.DataSource = rd;

shiny13 2-Feb-13 10:10am
in this case you can take the DataTable MyTable and count the rows maybe to see how many rows it has like this:
int count = MyTable.Rows.Count();

Or maybe to be extra sure try a for each loop and loop through the items and increment the count:
int count = 0;
foreach(var item in MyTable)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web02 | 2.8.171114.1 | Last Updated 2 Feb 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100