antony victor

antony victor

  • NA
  • 90
  • 22.2k

how to add category and subcategory in sqlserver

Jun 15 2013 3:33 AM
Basically its a Content management system.

I have designed the frontend in asp.net c# and also backend is sqlserver 
I have a category page where i have categoryname and image
In next page i have subcategory where i have to select the entered category name in dropdownlist and 
then add subcategory name , image and description .


can any one help me with the ado.net connections please as i am new to asp.net

My category page is below

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="category.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div id="wrapper">
<div id="container">
    <div id="content">
<div align="center" style=" padding-bottom:20px";>

           <table cellspacing="2" cellpadding="6" border="1" style="border:#d4cd0c solid 1px; padding:10px;">
       
            <tr>
                <td style="height: 58px">
                Add Category:
                </td>
                <td style="width: 171px; height: 58px">
                    <asp:TextBox ID="TextBox1" runat="server" ValidationGroup="v1"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Category name required" ValidationGroup="v1" ControlToValidate="TextBox1">*</asp:RequiredFieldValidator>
                </td>
             </tr>
            <tr>
            <td>
            Select Image (Resolution 92*82):
            </td>
            <td>
                <asp:FileUpload ID="FileUpload1" runat="server" />
                <asp:Image ID="Image2" runat="server"  Width="150" Height="150"/>
            </td>
            </tr>
            <tr>
                <td style="height: 137px">
                    <asp:ValidationSummary ID="ValidationSummary1" runat="server" 
                        ShowMessageBox="True" ShowSummary="False" ValidationGroup="v1" />
                </td>
                <td style="width: 171px; height: 137px">
                     <asp:Button ID="Button2" runat="server" Text="Add Category" 
                         onclick="Button2_Click" ValidationGroup="v1" />
                </td>
            </tr>
            </table>
            <br /><br />
            
            <table cellspacing="2" cellpadding="6">
          
            <tr>
            
                <td>
                    <asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" 
                        onrowdeleting="GridView2_RowDeleting" DataKeyNames="id" CellPadding="8" 
                        CellSpacing="4" onselectedindexchanged="GridView2_SelectedIndexChanged">
                        <Columns>
                            <asp:BoundField DataField="cname" HeaderText="Category" />
                            <asp:CommandField HeaderText="Delete" ShowDeleteButton="True" />
                        </Columns>
                    
                    </asp:GridView>
                    <asp:Label ID="Label1" runat="server" Text="No Category added till now"></asp:Label>
                </td>
            </tr>
          </table>
        
</div>
</div>
</div>
</asp:Content>
</div>
</div>
    </form>
</body>
</html>





My subcategory page is below


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="category.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div id="wrapper">
<div id="container">
    <div id="content">
<div align="center" style=" padding-bottom:20px";>

           <table cellspacing="2" cellpadding="6" border="1" style="border:#d4cd0c solid 1px; padding:10px;">
       
            <tr>
                <td style="height: 58px">
                Add Category:
                </td>
                <td style="width: 171px; height: 58px">
                    <asp:TextBox ID="TextBox1" runat="server" ValidationGroup="v1"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Category name required" ValidationGroup="v1" ControlToValidate="TextBox1">*</asp:RequiredFieldValidator>
                </td>
             </tr>
            <tr>
            <td>
            Select Image (Resolution 92*82):
            </td>
            <td>
                <asp:FileUpload ID="FileUpload1" runat="server" />
                <asp:Image ID="Image2" runat="server"  Width="150" Height="150"/>
            </td>
            </tr>
            <tr>
                <td style="height: 137px">
                    <asp:ValidationSummary ID="ValidationSummary1" runat="server" 
                        ShowMessageBox="True" ShowSummary="False" ValidationGroup="v1" />
                </td>
                <td style="width: 171px; height: 137px">
                     <asp:Button ID="Button2" runat="server" Text="Add Category" 
                         onclick="Button2_Click" ValidationGroup="v1" />
                </td>
            </tr>
            </table>
            <br /><br />
            
            <table cellspacing="2" cellpadding="6">
          
            <tr>
            
                <td>
                    <asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" 
                        onrowdeleting="GridView2_RowDeleting" DataKeyNames="id" CellPadding="8" 
                        CellSpacing="4" onselectedindexchanged="GridView2_SelectedIndexChanged">
                        <Columns>
                            <asp:BoundField DataField="cname" HeaderText="Category" />
                            <asp:CommandField HeaderText="Delete" ShowDeleteButton="True" />
                        </Columns>
                    
                    </asp:GridView>
                    <asp:Label ID="Label1" runat="server" Text="No Category added till now"></asp:Label>
                </td>
            </tr>
          </table>
        
</div>
</div>
</div>
</asp:Content>
</div>
</div>
    </form>
</body>
</html>


Answers (1)