Click here to Skip to main content
15,909,953 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
http://i.stack.imgur.com/vnvHt.png[^]

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
Comments
[no name] 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?

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";






regards!
 
Share this answer
 
use datatable or list to store your values, then assign the values to the datasource of your gridview.
 
Share this answer
 
Comments
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;

MyTable.Rows.Add(rd);


GridView1.DataSource = rd;


GridView1.DataBind();
}`
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)
{
count++;
}

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900