antony victor

antony victor

  • NA
  • 90
  • 22k

how to store an image and textbox in sqlserver ?

Jun 21 2013 6:11 AM
I have a category module in which i  have a  text box and image and I have a gridview on the same page
I want to save textbox and image values on sql server and as well display it on gridview.
I want to store the image in varchar format in database and not as image datatype.
apart from handler , is there any method?

Can anyone help me with the ado connections and  design table in sqlserver .

Below is my category page



<div id="wrapper">
<div id="container">
                <div align="center" style="padding-top:20px;">
    <div align="center">
    <table width="800" cellpadding="8" cellspacing="4" style="border:#FF6600 solid 1px; padding:10px 0px 0px 10px">
    <tbody align="left">
    <tr>
    <td>
        Category Name:</td>
    <td>
        <asp:TextBox ID="TextBox1" runat="server" ValidationGroup="v1" 
            ontextchanged="TextBox1_TextChanged"></asp:TextBox>
        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
            ControlToValidate="TextBox1" ErrorMessage="Ad Name 1 required" 
            ValidationGroup="v1">*</asp:RequiredFieldValidator>
    </td>
    <td>
        &nbsp;</td>
    </tr>
    <tr>
    <td>
    Add Image1:
    </td>
    <td>
        <asp:FileUpload ID="FileUpload1" runat="server" />
        <asp:Image ID="Image1" runat="server" Width="150" Height="150" />
    </td>
    </tr>
    <tr>
        <%--<td>
        Description 1:</td>
    <td>
        <asp:TextBox ID="TextBox3" runat="server" TextMode="MultiLine" 
            ValidationGroup="v1" ontextchanged="TextBox3_TextChanged"></asp:TextBox>
        (only 50 characters allowed)<asp:RequiredFieldValidator 
            ID="RequiredFieldValidator3" runat="server" ControlToValidate="TextBox3" 
            ErrorMessage="Description 1 required" ValidationGroup="v1">*</asp:RequiredFieldValidator>
    </td>--%>
    <td>
        &nbsp;</td>
    </tr>
    <tr>
    <td>
    </td>
    <td>
        <asp:Button ID="Button1" runat="server" Text="Add" onclick="Button1_Click" 
            ValidationGroup="v1" />
        <asp:Button ID="Button2" runat="server" Text="Update" onclick="Button2_Click" 
            ValidationGroup="v1" />
    </td>
    </tr>
    <tr>
    <td>
        &nbsp;</td>
    <td>
        <asp:ValidationSummary ID="ValidationSummary1" runat="server" 
            ShowMessageBox="True" ShowSummary="False" ValidationGroup="v1" />
    </td>
    </tr>
    </tbody>
    </table>
    <br /><br />
    <table>
    <tr>
    <td>
        <asp:Label ID="Label1" runat="server" ></asp:Label></td>
    </tr>
    <tr><td>
        <asp:GridView ID="GridView1" runat="server"  DataKeyNames="id" 
            AutoGenerateColumns="false"    BorderColor="#FF6600" 
                           BorderWidth="1px" CellPadding="10" CellSpacing="4" 
                           GridLines="None" HorizontalAlign="Center" 
            onpageindexchanging="GridView1_PageIndexChanging"  PageSize="10"
            onrowdeleting="GridView1_RowDeleting" AllowPaging="True" 
            onselectedindexchanged="GridView1_SelectedIndexChanged">
             <RowStyle BackColor="#CCFFFF" Height="30px" HorizontalAlign="Center" />
            <Columns>
            <asp:TemplateField HeaderText="Category Name"> 
          <ItemTemplate>
              <asp:Label ID="Label3" runat="server" Text= <%#Bind("cname") %> Width="200"></asp:Label>
                   </ItemTemplate>
          </asp:TemplateField>
            
            
          <asp:TemplateField HeaderText="Image1"> 
          <ItemTemplate>
              <asp:Image ID="Image1" runat="server" Width="200" Height="200" ImageUrl=<%#Bind("simage") %>/>
          </ItemTemplate>
          </asp:TemplateField>
          
             <%--<asp:TemplateField HeaderText="Description"> 
          <ItemTemplate>
              <asp:Label ID="Label4" runat="server" Text=<%#Bind("desc1") %> Width="200"></asp:Label>    </ItemTemplate>
          </asp:TemplateField>
          --%>
          
       
         
          
             <asp:TemplateField >
                <ItemTemplate>
                     <a href="category.aspx?id=<%# Eval("id") %>"> 
                         <asp:Label ID="Label2" runat="server" Text="Edit" Width="50"></asp:Label>
                     </a>
                </ItemTemplate>
            </asp:TemplateField>
        
            <%--    <asp:CommandField ShowDeleteButton="True" />--%>
            </Columns>
            <FooterStyle BackColor="#E4E4ED" HorizontalAlign="Center" />
                           <PagerStyle HorizontalAlign="Center" />
                           <HeaderStyle BackColor="#52CB25"  ForeColor="White" />
                           <AlternatingRowStyle BackColor="#86E263" />
        </asp:GridView>
    </td></tr>
    </table>
    </div>
   </div>

Answers (4)