Click here to Skip to main content
15,935,259 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
actually i'am using grid view in that it head retrieve sum textboxs and dropdownlists details i planing to add one button at last of the row last column

What I have tried:

<asp:TemplateField HeaderText="save"
                   < FooterStyle HorizontalAlign="Right" VerticalAlign="Bottom"                     FooterTemplate >
                 <       asp:Button ID="Button1" runat="server" Text="save" >
                   < FooterTemplate > 
             <  asp:TemplateField >

i'am trying this but the save button is add on every row off the last column.
please give me hints
Updated 2-Sep-16 1:14am
Karthik_Mahalingam 5-May-16 2:26am    
check my updated solution.
Nagarjuna99 5-May-16 2:36am    
i have another doubt that is i'am taking save button,what my requirement i press save button the the multiple number of rows will be save on database ?
is it possible?

try this

<asp:GridView ID="GridView1" runat="server" ShowFooter="true" AutoGenerateColumns="false">
               <asp:BoundField DataField="itemname" HeaderText="itemname" />
               <asp:BoundField DataField="itemprice" HeaderText="itemprice" />
               <asp:BoundField DataField="quantity" HeaderText="quantity" />
               <asp:BoundField DataField="tax" HeaderText="tax" />
               <asp:TemplateField  HeaderText="finalamount">
                       <asp:Label  Text='<%# Eval("finalamount") %>' runat="server" />
                       <asp:Button Text="Save" runat="server" />
Share this answer
Nagarjuna99 5-May-16 2:44am    
button was not added
Karthik_Mahalingam 5-May-16 2:55am    
Nagarjuna99 5-May-16 2:57am    
show footer="true",now its working,
i'have another question when i press button ,the multiple rows of data will be save in database? how to do this
Karthik_Mahalingam 5-May-16 3:07am    
check this
you will get.Insert all gridview data into a table[^]
Nagarjuna99 5-May-16 5:34am    
for (int i = 0; i < GridView1.Rows.Count; i++)
string name = GridView1.Rows[i].Cells[0].Text;
string price = GridView1.Rows[i].Cells[1].Text;
string quantity = GridView1.Rows[i].Cells[2].Text;
string tax = GridView1.Rows[i].Cells[3].Text;
string final = GridView1.Rows[i].Cells[4].Text;

SqlConnection con = new SqlConnection("Data Source=XENORIX8-PC;Initial Catalog=xenorix;User ID=sa;Password=123");
string str = "insert into quantity1 values('" + name + "','" + price + "','"+quantity+"','"+tax+"','"+final+"')";
SqlCommand strCmd = new SqlCommand(str, con);

i'am using this code to save grid view data into database ,but it has one problem that is final amount will save on 0.00.i think its not taking label 6 value off final amount what i do now?
Any control you add in footer will show in footer only. You are not doing it properly.
This is very basic thing. You need to go through some tutorial documents.

Inserting a New Record from the GridView's Footer (C#) | The ASP.NET Site[^]

Working with Footer Template in Gridview. -[^]

Displaying Summary Information in the GridView's Footer (VB) | The ASP.NET Site[^]


<asp:TemplateField HeaderText="Your header text">
                         <!-- your template control -->

                           <asp:Button ID="Button1" runat="server" Text="save" />
Share this answer
Nagarjuna99 5-May-16 2:00am    
i now but ,the html code was not coming properly in that so i removeing,
<asp:TemplateField HeaderText="save">
<footerstyle horizontalalign="Right" verticalalign="Bottom">
<asp:Button ID="Button1" runat="server" Text="save" />

this is my code
please and check what i wrong
Nagarjuna99 5-May-16 2:01am    
<asp:TemplateField HeaderText="save">
<footerstyle horizontalalign="Right" verticalalign="Bottom">
<asp:Button ID="Button1" runat="server" Text="save" />

Raje_ 5-May-16 2:07am    
check my edited answer. You see i have taken separate footer template for button.
Nagarjuna99 5-May-16 2:47am    
in that case button was not displaying
Raje_ 5-May-16 2:50am    
Did you add ShowFooter="true" to your grid view???
How to calculate time column .. Like if we have 2 column of datetime i want to multiply both columns value in 3rd column...How to do it?
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