I have one doubt
actually i am submitting data (id,name & image) in database (sql server 2012) but after submission image path is in hexa-decimal for rather than path of the image.
public partial class insertcategory : System.Web.UI.Page
{
myclass c1= new myclass();
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnsubmit_cgr_Click(object sender, EventArgs e)
{
string str = null;
if(FileUpload1.HasFile)
{
str="~/admin_cgr_image/" + FileUpload1.FileName;
FileUpload1.SaveAs(Server.MapPath(str));
}
string qu = "insert into Admin_New_Cgrr(cat_id,cat_name,cat_image)values(" + txtbox_catid.Text + ",'" + txtbox_catname.Text + "','" + str + "')";
bool isvalidate = c1.executesql(qu);
if (isvalidate == true)
{
lblmsg_cgr.Visible = true;
lblmsg_cgr.Text = "Record Submitted";
}
else
{
lblmsg_cgr.Visible = true;
lblmsg_cgr.Text = "Error occurred, please try again..!!!";
}
}
}
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<div class="admin_new_cgr">
<fieldset style="height:450px; text-align:center;">
<legend>
<h1>Add New Category</h1>
</legend>
<table class="auto-style1">
<tr>
<td class="auto-style4"> </td>
<td> </td>
</tr>
<tr>
<td class="auto-style4">Category_ID :</td>
<td style="text-align: left">
<asp:TextBox ID="txtbox_catid" runat="server" required="required" AutoPostBack="True"></asp:TextBox>
</td>
</tr>
<tr>
<td class="auto-style4"> </td>
<td> </td>
</tr>
<tr>
<td class="auto-style4">Category_Name :</td>
<td style="text-align: left">
<asp:TextBox ID="txtbox_catname" runat="server" required="required"></asp:TextBox>
</td>
</tr>
<tr>
<td class="auto-style4"> </td>
<td> </td>
</tr>
<tr>
<td class="auto-style4">Image :</td>
<td class="auto-style3">
<asp:FileUpload ID="FileUpload1" runat="server" style="text-align: center" />
</td>
</tr>
<tr>
<td class="auto-style2"> </td>
<td style="text-align: left">
<asp:Label ID="lblmsg_cgr" runat="server" Text="*"></asp:Label>
</td>
</tr>
<tr>
<td class="auto-style2"> </td>
<td style="text-align: left">
<asp:Button ID="btnsubmit_cgr" runat="server" Height="46px" Text="Submit" Width="143px" OnClick="btnsubmit_cgr_Click" />
</td>
</tr>
</table>
</fieldset>
</div>
</asp:Content>