Lans Trinh

Lans Trinh

  • NA
  • 1
  • 0

Help Search Function not working when using masterpage

Nov 15 2007 1:09 PM
Hi,
It's working fine when for Search Function When I use:
Customer.aspx
******************************************************************************************
<%@ Page Language="C#" AutoEventWireup="true" %>
<%@ Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
    Namespace="System.Web.UI" 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 id="Head1" runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <table border="1" width="100%">
            <tr align="center">
                <td colspan="10">Test Customer</td>
            </tr><tr><td><br /></td></tr>
            <tr>
                <td colspan="3" class="FieldDspl">
                    Search By Name:</td>
                <td colspan="7">
                    &nbsp;<asp:TextBox ID="Name" runat="server"></asp:TextBox>&nbsp;
                </td>
            </tr>
            <tr align="center"><td colspan="10" style="height: 47px">           
                <input id="cmdUpload" type="submit" value="Submit"  />         
            </td></tr>
             <tr><td  colspan="10">
                 &nbsp;&nbsp;
                 <asp:ScriptManager ID="ScriptManager1" runat="server">
                 </asp:ScriptManager>
                 <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                     <ContentTemplate>
                 <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True"
                     AutoGenerateColumns="False" DataKeyNames="Code" DataSourceID="SqlDataSource1" BackColor="White" BorderColor="#999999" BorderStyle="None" BorderWidth="1px" CellPadding="3" GridLines="Vertical">
                     <Columns>
                         <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
                         <asp:BoundField DataField="Code" HeaderText="Code" InsertVisible="False" ReadOnly="True"
                             SortExpression="Code" />
                         <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
                         <asp:BoundField DataField="Gender" HeaderText="Gender" SortExpression="Gender" />
                         <asp:BoundField DataField="City" HeaderText="City" SortExpression="City" />
                         <asp:BoundField DataField="State" HeaderText="State" SortExpression="State" />
                         <asp:BoundField DataField="Type" HeaderText="Type" SortExpression="Type" />
                     </Columns>
                     <FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
                     <RowStyle BackColor="#EEEEEE" ForeColor="Black" />
                     <SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
                     <PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
                     <HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" />
                     <AlternatingRowStyle BackColor="#DCDCDC" />
                 </asp:GridView>
                     </ContentTemplate>
                 </asp:UpdatePanel>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
                        SelectCommand="SELECT * FROM [Customer] WHERE ([Name] LIKE '%' + @Name + '%')" ConflictDetection="CompareAllValues" DeleteCommand="DELETE FROM [Customer] WHERE [Code] = @original_Code AND [Name] = @original_Name AND [Gender] = @original_Gender AND [City] = @original_City AND [State] = @original_State AND [Type] = @original_Type" InsertCommand="INSERT INTO [Customer] ([Name], [Gender], [City], [State], [Type]) VALUES (@Name, @Gender, @City, @State, @Type)" OldValuesParameterFormatString="original_{0}" UpdateCommand="UPDATE [Customer] SET [Name] = @Name, [Gender] = @Gender, [City] = @City, [State] = @State, [Type] = @Type WHERE [Code] = @original_Code AND [Name] = @original_Name AND [Gender] = @original_Gender AND [City] = @original_City AND [State] = @original_State AND [Type] = @original_Type">
            <DeleteParameters>
                <asp:Parameter Name="original_Code" Type="Int32" />
                <asp:Parameter Name="original_Name" Type="String" />
                <asp:Parameter Name="original_Gender" Type="String" />
                <asp:Parameter Name="original_City" Type="String" />
                <asp:Parameter Name="original_State" Type="String" />
                <asp:Parameter Name="original_Type" Type="String" />
            </DeleteParameters>
            <UpdateParameters>
                <asp:Parameter Name="Name" Type="String" />
                <asp:Parameter Name="Gender" Type="String" />
                <asp:Parameter Name="City" Type="String" />
                <asp:Parameter Name="State" Type="String" />
                <asp:Parameter Name="Type" Type="String" />
                <asp:Parameter Name="original_Code" Type="Int32" />
                <asp:Parameter Name="original_Name" Type="String" />
                <asp:Parameter Name="original_Gender" Type="String" />
                <asp:Parameter Name="original_City" Type="String" />
                <asp:Parameter Name="original_State" Type="String" />
                <asp:Parameter Name="original_Type" Type="String" />
            </UpdateParameters>
            <SelectParameters>
                <asp:FormParameter FormField="Name" Name="Name" Type="String" />
            </SelectParameters>
            <InsertParameters>
                <asp:Parameter Name="Name" Type="String" />
                <asp:Parameter Name="Gender" Type="String" />
                <asp:Parameter Name="City" Type="String" />
                <asp:Parameter Name="State" Type="String" />
                <asp:Parameter Name="Type" Type="String" />
            </InsertParameters>
        </asp:SqlDataSource>    
                
            </td></tr>
</table>     
    </div>
    </form>
</body>
</html>

******************************************************************************************
BUT IT DOESN'T WORK when using masterpage
Customer.Master
******************************************************************************************
<%@ Master Language="C#" AutoEventWireup="true" %>
<!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>
    <link href="CSS/Elicense.css" rel="stylesheet" type="text/css" />
    <title>Test Master Page</title>
</head>
<body runat="server">
    <form id="ACH" runat="server" method="Post">
        <table border="1" width="100%">
            <tr>
                <td valign="top" colspan="2">
                </td>
                <td colspan="8">
                    <asp:ContentPlaceHolder ID="FormContainner" runat="server">
                    </asp:ContentPlaceHolder>               
                </td>
            </tr>
        </table>
    </form>   
</body>
</html>
****************************************************************************

CustomerMP.aspx
****************************************************************************
<%@ Page Language="C#" MasterPageFile="~/Customer.Master" AutoEventWireup="true"%>
<%@ Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
    Namespace="System.Web.UI" TagPrefix="asp" %>
   
<asp:Content id="DisplayContent" ContentPlaceHolderID="FormContainner" runat="server"> 
 <table border="1" width="100%">
            <tr align="center">
                <td colspan="10">Test Customer With MasterPage</td>
            </tr><tr><td><br /></td></tr>
            <tr>
                <td colspan="3" class="FieldDspl">
                    Search By Name:</td>
                <td colspan="7">
                    &nbsp;<asp:TextBox ID="Name" runat="server"></asp:TextBox>&nbsp;
                </td>
            </tr>
            <tr align="center"><td colspan="10" style="height: 47px">           
                <asp:Button ID="cmdUpload" runat="server" Text="Submit" />
            </td></tr>
             <tr><td  colspan="10">
                 &nbsp;&nbsp;
                 <asp:ScriptManager ID="ScriptManager1" runat="server">
                 </asp:ScriptManager>
                 <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                     <ContentTemplate>
                 <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True"
                     AutoGenerateColumns="False" DataKeyNames="Code" DataSourceID="SqlDataSource1" BackColor="White" BorderColor="#999999" BorderStyle="None" BorderWidth="1px" CellPadding="3" GridLines="Vertical">
                     <Columns>
                         <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
                         <asp:BoundField DataField="Code" HeaderText="Code" InsertVisible="False" ReadOnly="True"
                             SortExpression="Code" />
                         <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
                         <asp:BoundField DataField="Gender" HeaderText="Gender" SortExpression="Gender" />
                         <asp:BoundField DataField="City" HeaderText="City" SortExpression="City" />
                         <asp:BoundField DataField="State" HeaderText="State" SortExpression="State" />
                         <asp:BoundField DataField="Type" HeaderText="Type" SortExpression="Type" />
                     </Columns>
                     <FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
                     <RowStyle BackColor="#EEEEEE" ForeColor="Black" />
                     <SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
                     <PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
                     <HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" />
                     <AlternatingRowStyle BackColor="#DCDCDC" />
                 </asp:GridView>
                     </ContentTemplate>
                 </asp:UpdatePanel>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
                        SelectCommand="SELECT * FROM [Customer] WHERE ([Name] LIKE '%' + @Name + '%')" ConflictDetection="CompareAllValues" DeleteCommand="DELETE FROM [Customer] WHERE [Code] = @original_Code AND [Name] = @original_Name AND [Gender] = @original_Gender AND [City] = @original_City AND [State] = @original_State AND [Type] = @original_Type" InsertCommand="INSERT INTO [Customer] ([Name], [Gender], [City], [State], [Type]) VALUES (@Name, @Gender, @City, @State, @Type)" OldValuesParameterFormatString="original_{0}" UpdateCommand="UPDATE [Customer] SET [Name] = @Name, [Gender] = @Gender, [City] = @City, [State] = @State, [Type] = @Type WHERE [Code] = @original_Code AND [Name] = @original_Name AND [Gender] = @original_Gender AND [City] = @original_City AND [State] = @original_State AND [Type] = @original_Type">
            <DeleteParameters>
                <asp:Parameter Name="original_Code" Type="Int32" />
                <asp:Parameter Name="original_Name" Type="String" />
                <asp:Parameter Name="original_Gender" Type="String" />
                <asp:Parameter Name="original_City" Type="String" />
                <asp:Parameter Name="original_State" Type="String" />
                <asp:Parameter Name="original_Type" Type="String" />
            </DeleteParameters>
            <UpdateParameters>
                <asp:Parameter Name="Name" Type="String" />
                <asp:Parameter Name="Gender" Type="String" />
                <asp:Parameter Name="City" Type="String" />
                <asp:Parameter Name="State" Type="String" />
                <asp:Parameter Name="Type" Type="String" />
                <asp:Parameter Name="original_Code" Type="Int32" />
                <asp:Parameter Name="original_Name" Type="String" />
                <asp:Parameter Name="original_Gender" Type="String" />
                <asp:Parameter Name="original_City" Type="String" />
                <asp:Parameter Name="original_State" Type="String" />
                <asp:Parameter Name="original_Type" Type="String" />
            </UpdateParameters>
            <SelectParameters>
                <asp:FormParameter FormField="Name" Name="Name" Type="String" />
            </SelectParameters>
            <InsertParameters>
                <asp:Parameter Name="Name" Type="String" />
                <asp:Parameter Name="Gender" Type="String" />
                <asp:Parameter Name="City" Type="String" />
                <asp:Parameter Name="State" Type="String" />
                <asp:Parameter Name="Type" Type="String" />
            </InsertParameters>
        </asp:SqlDataSource>    
                
            </td></tr>
</table>   
    </asp:Content>
****************************************************************************
I couldn't find the problem why.  Pls HELP. 
Thanks.

Lans