Click here to Skip to main content
15,886,799 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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;
    }
}


XML
<%@ 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>
                &nbsp;</td>
        </tr>
    </table>
        <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
           </asp:ToolkitScriptManager>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;


      </div>
    </form>
</body>
</html>
Posted
Updated 20-Apr-11 0:02am
v3
Comments
walterhevedeich 20-Apr-11 6:02am    
This isnt a question.
Prerak Patel 20-Apr-11 6:04am    
What is the problem?
Henry Minute 20-Apr-11 6:35am    
If you are trying to demonstrate your programming skills, this is not the correct place.
Post it in Tips/Tricks or write an Article about it.
[no name] 20-Apr-11 7:12am    
Not Single word on question
Sandeep Mewara 20-Apr-11 10:14am    
And... the question is?

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