Sunday, April 10, 2016
Wednesday, March 2, 2016
Monday, February 8, 2016
Sunday, February 7, 2016
Thursday, February 4, 2016
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>
Wednesday, February 3, 2016
Tuesday, February 2, 2016
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
<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
Sunday, January 31, 2016
how to create delete button in asp net
use Below code for delete data from Sql server in asp.net :
Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Try
Dim RowsAffected As Integer = 0
con.Open()
Dim cq As String = String.Format("delete from UnitType where UnitTypeID= {0}", TextBox1.Text)
cmd = New SqlCommand(cq) With {.Connection = con}
RowsAffected = cmd.ExecuteNonQuery()
Label5.Text = "Successfully deleted"
FillGrid()
TextBox1.Text = ""
TextBox2.Text = ""
If con.State = ConnectionState.Open Then
con.Close()
End If
Catch ex As Exception
Response.Write(ex.Message)
End Try
End Sub
how to use autocomplete in asp net
Use Below Code to show data in Textbox in Asp.net :
<System.Web.Script.Services.ScriptMethod(), System.Web.Services.WebMethod()>
Public Shared Function SearchUnit(ByVal prefixText As String, ByVal count As Integer) As List(Of String)
Dim con As SqlConnection = New SqlConnection
con.ConnectionString = ConfigurationManager.ConnectionStrings("MTechSqlDatabaseConnectionString").ConnectionString
Dim cmd As SqlCommand = New SqlCommand
cmd.CommandText = String.Format("select UnitType from UnitType where UnitType LIKE '%{0}%' ", prefixText)
'
cmd.Parameters.AddWithValue("@ProductName", prefixText)
cmd.Connection = con
con.Open()
Dim UnitType As List(Of String) = New List(Of String)
Dim sdr As SqlDataReader = cmd.ExecuteReader
While sdr.Read
UnitType.Add(sdr("UnitType").ToString)
End While
con.Close()
Return UnitType
End Function
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="True"></asp:ScriptManager>
<asp:TextBox ID="TextBox4" runat="server"></asp:TextBox>
<ajaxToolkit:AutoCompleteExtender ID="AutoCompleteExtender2" runat="server" CompletionInterval="100" EnableCaching="False" MinimumPrefixLength="1" ServiceMethod="SearchUnit" TargetControlID="TextBox4"></ajaxToolkit:AutoCompleteExtender>
</div>
how to open a page in new tab on button click in asp net
Below Code Open only one new Tab and if you click again it refresh that page:
Protected Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
Page.ClientScript.RegisterStartupScript(Me.GetType, "OpenWindow", "window.open('UnitType.aspx','_newtab');", True)
End Sub
Below Code Open new Tab and if you click again it will open another new tab page:
<asp:Button ID="Button7" runat="server" Text=">>" OnClientClick="document.getElementById('form1').target ='_blank';" /> Protected Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click Response.Redirect("Authors.aspx") End SubSaturday, January 30, 2016
Friday, January 29, 2016
Wednesday, January 27, 2016
Tuesday, January 26, 2016
Subscribe to:
Posts (Atom)
MM Online Express | Best product Review and Online Marketing site
MM Online Express | Best product Review and Online Marketing site