ASp.net

Thursday, February 4, 2016

how to save data from gridview to database in asp net

Using the ListView Control to Add Data in ASP NET




<asp:ListView ID="ListView1" runat="server"
InsertItemPosition="FirstItem" DataSourceID="SqlDataSource1">
<LayoutTemplate>
<asp:PlaceHolder ID="itemPlaceholder" runat="server" />
</LayoutTemplate>
<ItemTemplate>
<div>
CustomerName: <%# Eval("CustomerName")%><br />
CustomerAddress: <%# Eval("CustomerAddress")%>
</div>
</ItemTemplate>
<InsertItemTemplate>
<div>
CustomerName: <asp:TextBox ID="txtName" runat="server" Text='<%# Bind("CustomerName")%>' /><br />
CustomerAddress: <asp:TextBox ID="txtAge" runat="server" Text='<%# Bind("CustomerAddress")%>' /><br />
<asp:Button ID="butInsert" runat="server" CommandName="Insert" Text="Add" />
</div>
</InsertItemTemplate>
</asp:ListView>

<asp:SqlDataSource ID="SqlDataSource1" runat="server"
SelectCommand="SELECT * FROM Customer"
InsertCommand="INSERT Customer (CustomerName,CustomerAddress) VALUES (@CustomerName,@CustomerAddress)"
ConnectionString="<%$ ConnectionStrings:MTechSqlDatabaseConnectionString %>" >
</asp:SqlDataSource>

Tuesday, February 2, 2016

How to use view and Multiview Control in ASP NET

how to use formview control in asp net

how to pass values from textbox into listview click buttons in asp.net

<div style="overflow: scroll; height: 100%; width: 750px">
                    <asp:ListView ID="ListView1" runat="server">
                    <LayoutTemplate>
                        <table id="Table1" runat="server" border="1">
                            <tr id="Tr1" runat="server">
                                <th id="Th1" runat="server">ID</th>
                                <th id="Th2" runat="server">Product Name</th>
                                <th id="Th3" runat="server">Buy Price</th>
                                <th id="Th4" runat="server">Quantity</th>
                                <th id="Th5" runat="server">Unit Type</th>
                                <th id="Th6" runat="server">Sub Amount</th>
                                <th id="Th7" runat="server">Discount Percent</th>
                                <th id="Th8" runat="server">Discount Amount</th>
                                <th id="Th9" runat="server">Extra Cost</th>
                                <th id="Th10" runat="server">Closing Unit Price</th>
                                <th id="Th11" runat="server">Amount</th>
                                <th id="Th12" runat="server">Rack</th>
                                <th id="Th13" runat="server">Supplier</th>
                            </tr>
                             <tr runat="server" id="ItemPlaceholder">
                            </tr>
                        </table>
                    </LayoutTemplate>
                    <ItemTemplate>
                        <tr id="Tr2" runat="server">
                            <td id="Td1" runat="server"> <%#Eval("ID")%></td>
                            <td id="Td2" runat="server"> <%#Eval("Product Name")%></td>
                            <td id="Td3" runat="server"> <%#Eval("Buy Price")%></td>
                            <td id="Td4" runat="server"> <%#Eval("Quantity")%></td>
                            <td id="Td5" runat="server"> <%#Eval("Unit Type")%></td>
                            <td id="Td6" runat="server"> <%#Eval("Sub Amount")%></td>
                            <td id="Td7" runat="server"> <%#Eval("Discount Percent")%></td>
                            <td id="Td8" runat="server"> <%#Eval("Discount Amount")%></td>
                            <td id="Td9" runat="server"> <%#Eval("Extra Cost")%></td>
                            <td id="Td10" runat="server"> <%#Eval("Closing Unit Price")%></td>
                            <td id="Td11" runat="server"> <%#Eval("Amount")%></td>
                            <td id="Td12" runat="server"> <%#Eval("Rack")%></td>
                            <td id="Td13" runat="server"> <%#Eval("Supplier")%></td>
                           
                        </tr>
                    </ItemTemplate>
                </asp:ListView>
                </div>






Protected Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
     
                Dim dt As DataTable = New DataTable
                dt.Columns.Add("Id")
                dt.Columns.Add("Product Name")
                dt.Columns.Add("Buy Price")
                dt.Columns.Add("Quantity")
                dt.Columns.Add("Unit Type")
                dt.Columns.Add("Sub Amount")
                dt.Columns.Add("Discount Percent")
                dt.Columns.Add("Discount Amount")
                dt.Columns.Add("Extra Cost")
                dt.Columns.Add("Closing Unit Price")
                dt.Columns.Add("Amount")
                dt.Columns.Add("Rack")
                dt.Columns.Add("Supplier")
                dt.AcceptChanges()
                Dim dr As DataRow = dt.NewRow
                dr("Id") = TextBox11.Text
                dr("Product Name") = TextBox12.Text
                dr("Buy Price") = TextBox13.Text
                dr("Quantity") = TextBox14.Text
                dr("Unit Type") = Label5.Text
                dr("Sub Amount") = TextBox15.Text
                dr("Discount Percent") = TextBox16.Text
                dr("Discount Amount") = TextBox17.Text
                dr("Extra Cost") = TextBox19.Text
                dr("Closing Unit Price") = TextBox20.Text
                dr("Amount") = TextBox21.Text
                dr("Rack") = TextBox22.Text
                dr("Supplier") = TextBox6.Text
                dt.Rows.Add(dr)
                dt.AcceptChanges()
                ListView1.DataSource = dt
                ListView1.DataBind()
       
    End Sub

MM Online Express | Best product Review and Online Marketing site

MM Online Express | Best product Review and Online Marketing site