Click here to Skip to main content
15,894,825 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am inserting value from web form.

First item name selecting from drop down list then using item rate and quantity from text box.

I want all these values to come in a grid and when I have inserted all the values, calculate amount of all value and press submit to save these data and then save in database.
Posted
Updated 13-Sep-10 21:23pm
v2
Comments
Dalek Dave 14-Sep-10 3:23am    
Minor Edit for Grammar.

if u dont want to save the values entered in textbox u can create a temporary DataTable. Once the submit is clicked for the textboxes, fill the data entered in DataTable. give the gridview datasource as datatable.

Bind the gridview. Then you will be able to see the the entered values in gridview.

if everything is fine go for final submit and insert these values into database.

hope this helps u.. :)


Mohan Gajula
 
Share this answer
 
Comments
call to .net 14-Sep-10 3:04am    
what is the source code for such type of grid insertion records??
mohangbits 14-Sep-10 4:57am    
iam adding an example below for your info.
mohangbits 14-Sep-10 5:05am    
You can check the below answer with code
hello shivesh

once u get ur total according ur formulae,
den fire d insert query on click event of submit button,
and den fire d select query to fetch d data from database on same click event,
and provide datasource to the gridview...........

i hope it will hep u.......


plz rply me.....
 
Share this answer
 
Comments
Sandeep Mewara 14-Sep-10 5:03am    
Please avoid using TEXT SPEAK. This is a professional world and you should use proper words while writing instead of 'u,ur,d,plz...'

Else wise good work!
Please check this code
private DataTable CreateDataTable()
        {
            DataTable myDataTable = new DataTable();
            DataColumn myDataColumn;
            myDataColumn = new DataColumn();
            myDataColumn.DataType = Type.GetType("System.String");
            myDataColumn.ColumnName = "ItemName";
            myDataTable.Columns.Add(myDataColumn);
            myDataColumn = new DataColumn();
            myDataColumn.DataType = Type.GetType("System.String");
            myDataColumn.ColumnName = "ItemRate";
            myDataTable.Columns.Add(myDataColumn);
            myDataColumn = new DataColumn();
            myDataColumn.DataType = Type.GetType("System.String");
            myDataColumn.ColumnName = "ItemQty";
            myDataTable.Columns.Add(myDataColumn);
            //add records
            AddDataToTable("ItemName1", "ItemRate1", "ItemQty1", myDataTable);
            // In your case you can comment the above line and go like this
            //AddDataToTable(textBoxItemName.Text,ddlItemRate.SelectedValue, txtItemQty.Text,myDataTable);
            gvItems.DataSource = myDataTable;
            gvItems.DataBind();
            return myDataTable;
        }
        private void AddDataToTable(string strItemName, string strItemRate, string strItemQty, System.Data.DataTable myTable)
        {
            DataRow row;
            row = myTable.NewRow();
            row["ItemName"] = strItemName;
            row["ItemRate"] = strItemRate;
            row["ItemQty"] = strItemQty;
            myTable.Rows.Add(row);
        }

Hope this works :)
 
Share this answer
 

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