0

i have a textbox,button and datagrid
i want to add textbox value in grid on button click(with out database)
and finaly store this grid data in database(mySql)

i want to add multiple value from textbox to grid?

plz help

3
Contributors
2
Replies
3
Views
9 Years
Discussion Span
Last Post by diananizam
0

if you are determined to use the datagrid for that matter, cast datagrid datasource to a datatable on button click like this :
void button_click(object sender, EventArgs e)
{
DataTable dt = (DataTable)(datagrid1.DataSource);
dt.rows.Add(new object[]{TextBox1.Text});
datagrid1.DataSource = dt;
datagrid1.DataBind();
}

alternatively you can achieve that without datagrid, using javascript.
you can create an html table and then add new rows to it using javascript. At the end, you can copy the content of the html table to an input type=hidden runat=server, and then get the values from hidden field using c#, pass all the info to the dataset and save it to database using dataadapter.

The first one is more easy to implement but the second prevents you from postbacks and unneccessary network traffic.

0

Hi,

I am very need ur help..
I have multiple text box which is the user will key in the value.
There are 1 button "Print".
Can I know what code for Print button function to print out all the text box values.

Thanks for your help..

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.