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

Recommended Answers

All 2 Replies

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.

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..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.