Click here to Skip to main content
14,639,661 members
Rate this:
Please Sign up or sign in to vote.
on selecting dropdown list in gridview its rate has to be displayed in label of that row, in the same row quantity column is to make user to enter quantity in textbox. and the amount has to be displayed by calculating quantity* rate . and this gridview must be autogenerated.

What I have tried:

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"

                DataSourceID="SqlDataSource2" 

                 

                ShowHeaderWhenEmpty="True" ShowFooter="True"

                Width="595px" onselectedindexchanged="GridView1_SelectedIndexChanged" 

                ondatabinding="Page_Load">
                <columns>
                    <asp:TemplateField HeaderText="Sno" SortExpression="Sno">
                    
                        <edititemtemplate>
                            <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Sno") %>'>
                        
                        <itemtemplate>
                            <asp:Label ID="Label1" runat="server" Text='<%# Bind("Sno") %>'>
                        
                        <footertemplate>
                            <asp:LinkButton ID="LinkButton1" runat="server">Insert
                        
                        
                        
                    
                    <asp:TemplateField HeaderText="Product" SortExpression="Product">
                        
                        <itemtemplate>
                            <asp:Label ID="Labelt" runat="server" Text='<%# Bind("Product") %>'>
                        
                        <footertemplate>
                            <asp:DropDownList runat="server" DataSourceID="slsfConnectionString3" DataValueField="Prid"  DataTextField="Product" Id="ddp">
                             
                        
                    
                    <asp:TemplateField HeaderText="Quantity" SortExpression="Quantity">
                        
                        <itemtemplate>
                            <asp:Label ID="Label2" runat="server" Text='<%# Bind("Quantity") %>'>
                        
                        <footertemplate>
                        <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("Quantity") %>'>
                        
                    
                    <asp:TemplateField HeaderText="Rate" SortExpression="Rate">
                        <footertemplate>
                            <asp:Label ID="Label5" runat="server" Text='<%# Bind("Rate") %>' >
                        
                        <itemtemplate>
                            <asp:Label ID="Label3" runat="server" Text='<%# Bind("Rate") %>'>
                        
                    

                    <asp:TemplateField HeaderText="Amount" SortExpression="Amount">

                        <edititemtemplate>
                            <asp:TextBox ID="TextBox4" runat="server" Text='<%# Bind("Amount") %>'>
                        
                        <itemtemplate>
                            <asp:Label ID="Label4" runat="server" Text='<%# Bind("Amount") %>'>
                        
                        <footertemplate>
                        <asp:Label ID="Label6" runat="server" Text='<%# Eval("Amount") %>'>
Posted
Updated 3-May-17 1:26am
v2
Comments
ZurdoDev 3-May-17 7:19am
   
Decide if you want to use JavaScript or C# to do it and then tells us where you are stuck.

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

You can do that by server side and client side as well

There are many solutions available on google, You should check it.

For more info

How to do Calculations in GridView[^]

Calculate Running Total in ASP.Net GridView using jQuery[^]
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100