Click here to Skip to main content
15,891,248 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I select column from databse and I put then in datatable like that

C#
DataTable dtt = d.select("select ItemID,ItemName,SellingPrice,ImageUrl from TItem where ItemID in (" + oCookie.Value + ")");


and after that I put them in the gridview like that

C#
GridView2.DataSource =dtt;
 GridView2.DataBind();

now I have three column in grid

my question

how to add tow column too to the grid

first column is textbox to modify the quantity

second column is the total to calculate the total price???????????

help me please I had I lot of time to do and I didn't reach to it
Posted

1 solution

hi,
you can use DataTable.Compute to add an evaluating formula to a DataColumn. In order to add 'Sum' column you need to just add a column to the DataTable and ,then, use Compute method to define a formula for that column.
http://msdn.microsoft.com/en-us/library/system.data.datatable.compute.aspx[^]
In order to add a textbox to your grid, you can define a TemplateField in your grid, put a textbox in it and then define an event handler to run a particular code for changing it.

I hope it helps,
Cheers
 
Share this answer
 
v2
Comments
Sarah Mohammed77 27-Apr-12 9:32am    
how to add event handler to control inside gridview?
Reza Ahmadi 27-Apr-12 9:34am    
In your TemplateField, select your control, and just define an event handler as you do in a normal situation

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