Tuesday, December 13, 2011

UpdateParameters Session variable Gridview

<%@ Page Title="" Language="C#" MasterPageFile="MasterPage2.master" AutoEventWireup="true" CodeFile="ownerdet.aspx.cs" Inherits="ownerdet" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <form id="form1" runat="server">
    <center>

     <br />
        <b>Insert Owner</b>
        <br/>
        <table style="width: 60%">
            <tr>
                <td style="height: 17px">
                    <asp:Label ID="Label5" runat="server" Text="First Name"></asp:Label>
                </td>
                <td style="height: 17px">
                    <asp:Label ID="Label1" runat="server" Text="Last Name"></asp:Label>
                </td>
                <td style="height: 17px">
                    <asp:Label ID="Label2" runat="server" Text="Company"></asp:Label>
                </td>
                <td style="height: 17px">
                    <asp:Label ID="Label3" runat="server" Text="Email ID"></asp:Label>
                </td>
                <td style="height: 17px">
                    &nbsp;</td>
                <td style="height: 17px">
                    &nbsp;</td>
            </tr>
            <tr>
                <td>
                    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
                </td>
                <td>
                    <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
                </td>
                <td>
                    <asp:TextBox ID="TextBox3" runat="server" ></asp:TextBox>
                </td>
                <td>
                    <asp:TextBox ID="TextBox4" runat="server"></asp:TextBox>
                </td>
                <td>
                    <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Add" />
                </td>
                <td>
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                </td>
            </tr>
            <tr>
                <td>
                    &nbsp;</td>
                <td colspan="2">
                    <asp:Label ID="Label6" runat="server"
                        Text="Duplicate Owner , Do you want to continue?"></asp:Label>
                </td>
                <td>
                    <asp:Button ID="Button2" runat="server" onclick="Button2_Click" Text="Yes" />
                    <asp:Button ID="Button3" runat="server" onclick="Button3_Click" Text="No" />
                </td>
                <td>
                    &nbsp;</td>
                <td>
                    &nbsp;</td>
                <td>
                    &nbsp;</td>
            </tr>
        </table>
       
        <b> Owner Details</b>
    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
        CellPadding="4" DataSourceID="SqlDataSource1" ForeColor="#333333"  DataKeyNames="OWID"
        GridLines="None" AutoGenerateEditButton="true" AutoGenerateDeleteButton="true" AllowPaging="true" PageSize="10">
        <AlternatingRowStyle BackColor="White"   />
        <Columns>
            <asp:BoundField DataField="OWID" HeaderText="OWID" InsertVisible="False"
                ReadOnly="True" SortExpression="OWID" />
            <asp:BoundField DataField="OWFNAM" HeaderText="First Name"
                SortExpression="OWFNAM" />
            <asp:BoundField DataField="OWLNAM" HeaderText="Last Name"
                SortExpression="OWLNAM" />
            <asp:BoundField DataField="OWCOMP" HeaderText="Company"
                SortExpression="OWCOMP" />
            <asp:BoundField DataField="OWEMAL" HeaderText="Email Id"
                SortExpression="OWEMAL" />
           <asp:BoundField DataField="OWACTYN" HeaderText="Active(Y/N)"
                SortExpression="OWACTYN" />
          <asp:BoundField DataField="OWUSER" HeaderText="OWUSER"
                SortExpression="OWUSER"  ReadOnly="true" />
           <asp:BoundField DataField="OWUPMJ" HeaderText="Date Update"
                SortExpression="OWUPMJ" ReadOnly="true" />
          
               
        </Columns>
        <EditRowStyle BackColor="#2461BF" />
        <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
        <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
        <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
        <RowStyle BackColor="#EFF3FB" />
        <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
       
    </asp:GridView>
        <br />
        <asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False"
            DataSourceID="SqlDataSource2" Visible="false">
            <Columns>
                <asp:BoundField DataField="OWID" HeaderText="OWID" InsertVisible="False"
                    ReadOnly="True" SortExpression="OWID" />
            </Columns>
        </asp:GridView>
        <asp:SqlDataSource ID="SqlDataSource2" runat="server"
            ConnectionString="<%$ ConnectionStrings:ConnectionString51 %>"
            ></asp:SqlDataSource>
      
    </center>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server"
        ConnectionString="<%$ ConnectionStrings:ConnectionString51 %>"
        SelectCommand="SELECT [OWID], [OWFNAM], [OWLNAM], [OWCOMP], [OWEMAL],[OWACTYN],[OWUSER],[OWUPMJ] FROM [Owdetails]"
         UpdateCommand="update Owdetails set OWFNAM=@OWFNAM, OWLNAM=@OWLNAM, OWCOMP=@OWCOMP, OWEMAL=@OWEMAL,OWACTYN=@OWACTYN,OWUPMJ=@OWUPMJ,OWUSER=@OWUSER where OWID=@OWID"
          DeleteCommand="Delete FROM Owdetails where OWID=@OWID"
        >
        <UpdateParameters>
                    <asp:Parameter Name="OWFNAM" Type="String" />
                    <asp:Parameter Name="OWLNAM" Type="String" />
                    <asp:Parameter Name="OWCOMP" Type="String" />
                    <asp:Parameter Name="OWEMAL" Type="String" />
                    <asp:Parameter Name="OWACTYN" Type="String" />
                    <asp:SessionParameter Name="OWUPMJ" SessionField="datetime" Type="String" />
                    <asp:SessionParameter Name="OWUSER" SessionField="Usrid" Type="String" />
        
                </UpdateParameters>

    </asp:SqlDataSource>
    </form>
</asp:Content>

 

No comments: