using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data; using System.Data.SqlClient; public partial class productWithExtndr : System.Web.UI.Page { SqlConnection con = new SqlConnection("server=RND3-12\\MSSQLEXPDB;user id=sa;password=prayoglabs@123;database=IMS"); SqlDataAdapter da; DataSet ds; protected void Page_Load(object sender, EventArgs e) { if (Page.IsPostBack == false) { da = new SqlDataAdapter("select * from productdetails", con); ds = new DataSet(); da.Fill(ds, "productdetails"); gvUser.DataSource = ds.Tables["productdetails"]; gvUser.DataBind(); ddlpId.Items.Add("select"); for (int i = 0; i < ds.Tables["productdetails"].Rows.Count; i++) { ddlpId.Items.Add(ds.Tables["productdetails"].Rows[i][0].ToString()); } } } private void getdata() { da = new SqlDataAdapter("select * from productdetails", con); ds = new DataSet(); da.Fill(ds, "pd"); gvUser.DataSource = ds.Tables["pd"]; gvUser.DataBind(); } protected void btnSave_Click(object sender, EventArgs e) { SqlDataAdapter da1 = new SqlDataAdapter("select item_id from itemdetails where Item_Description='" + txtitemid.Text + "'", con); ds = new DataSet(); da1.Fill(ds, "itemdetails"); da = new SqlDataAdapter("insert into productdetails values('"+ddlpId.SelectedValue +"','" + ds.Tables["itemdetails"].Rows[0][0].ToString() + "'," + txtQty.Text + ")", con); ds = new DataSet(); da.Fill(ds, "productdetails"); getdata(); txtitemid.Text = txtQty.Text = ""; ddlpId.SelectedIndex = 0; } }
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="productWithExtndr.aspx.cs" Inherits="productWithExtndr" %> <%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="asp" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <script type="text/javascript"> function ShowProcessImage() { var autocomplete = document.getElementById('txtitemid'); autocomplete.style.backgroundImage = 'url(loading1.gif)'; autocomplete.style.backgroundRepeat = 'no-repeat'; autocomplete.style.backgroundPosition = 'right'; } function HideProcessImage() { var autocomplete = document.getElementById('txtitemid'); autocomplete.style.backgroundImage = 'none'; } function AfterSelectedText() { // alert(document.getElementById("txtCountry").value) if (document.getElementById("txtitemid").value == "ITEMNOTPRESENT") { // var objoverlay = document.getElementById("overlay"); // objoverlay.style.display = 'none'; window.open("productDetails.aspx", "", "width=800px, height=600px,resizable"); } } </script> <title></title> <style type="text/css"> .style1 { width: 31%; height: 41px; } .style2 { width: 32%; height: 22px; } </style> </head> <body> <form id="form1" runat="server"> <div style="height: 416px; width: 1144px"> <br /> <table bgcolor="#005959" class="style2"> <tr> <td> <asp:DropDownList ID="ddlpId" runat="server" Height="24px" Width="141px"> </asp:DropDownList> </td> </tr> </table> <br /> <asp:GridView ID="gvUser" runat="server" Width="368px" AutoGenerateColumns="False" CellPadding="4" ForeColor="#333333" GridLines="None" ShowFooter="True" Height="175px" style="margin-right: 46px" > <RowStyle BackColor="#E3EAEB" /> <Columns> <asp:TemplateField> <HeaderTemplate>ItemId</HeaderTemplate> <ItemTemplate> <%#Eval("item_id")%> </ItemTemplate> </asp:TemplateField> <asp:TemplateField> <HeaderTemplate>Quantity</HeaderTemplate> <ItemTemplate> <%#Eval("item_quantity")%> </ItemTemplate> </asp:TemplateField> </Columns> <FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" /> <PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" /> <SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" /> <HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" /> <EditRowStyle BackColor="#7C6F57" /> <AlternatingRowStyle BackColor="White" /> </asp:GridView> <br /> <table class="style1" bgcolor="#005959" > <tr> <td> <asp:TextBox ID="txtitemid" runat="server" Height="21px" Width="182px"></asp:TextBox> <asp:AutoCompleteExtender ID="txtitemid_AutoCompleteExtender" runat="server" DelimiterCharacters="" Enabled="True" ServicePath="productsWeb.asmx" ServiceMethod="GetCountries" MinimumPrefixLength="1" OnClientPopulating="ShowProcessImage" OnClientPopulated="HideProcessImage" OnClientItemSelected="AfterSelectedText" CompletionInterval="100" CompletionSetCount ="8" TargetControlID="txtitemid"> </asp:AutoCompleteExtender> </td> <td> <asp:TextBox ID="txtQty" runat="server" Height="22px" Width="173px"></asp:TextBox> </td> </tr> <tr> <td> <asp:Button ID="btnSave" runat="server" Text="Save" onclick="btnSave_Click" /> </td> <td> </td> </tr> </table> <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"> </asp:ToolkitScriptManager> </div> </form> </body> </html>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)