关于将数据存储到asp.net配置文件的问题? [英] Problem about to data storage into asp.net profile?

查看:64
本文介绍了关于将数据存储到asp.net配置文件的问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello Everybody,我正在开发小型购物网站项目,现在我正在使用cart_page,我想使用asp.net profile存储数据。但问题是当我运行项目时数据显示在调试过程中它没有存储到'ASPNETDB.MDF'数据库。所以请帮帮我:下面是我的代码:





Hello Everybody,I am working on the small shopping website project and now I am working on the cart_page and I want to store the data using asp.net profile.But the problem is that when I run the project the data is shown during the debugging but it is not store to the 'ASPNETDB.MDF' database.So please help me:Here's below is my code:


public partial class Default2 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

        if (!Page.IsPostBack)
        {
            ((Label)DataList1.Controls[0].FindControl("LblName")).Text = (Profile.Name).ToString();
            ((Image)DataList1.Controls[0].FindControl("Image1")).ImageUrl = (Profile.ImageUrl).ToString();
            (((TextBox)DataList1.Controls[0].FindControl("TxtItem")).Text) = (Profile.Item).ToString();
            (((Label)DataList1.Controls[0].FindControl("LblPrice")).Text) = (Profile.Price).ToString();
            Profile.Save();
        }
      }
    protected void Button1_Click(object sender, EventArgs e)
    {
        Profile.Name= ((Label)DataList1.Controls[0].FindControl("LblName")).Text;
        Profile.ImageUrl = ((Image)DataList1.Controls[0].FindControl("Image1")).ImageUrl;
        Profile.Item = int.Parse(((TextBox)DataList1.Controls[0].FindControl("TxtItem")).Text);
        Profile.Price = int.Parse(((Label)DataList1.Controls[0].FindControl("LblPrice")).Text);
        string ProductID = (Request.QueryString["ProductID"]);
        Profile.Save();
    }
}





和web.config的代码在这里:





and the code of web.config is here:

<connectionstrings>
   <add name="E-commerceConnectionString" connectionstring="Data Source=ps201\SQLEXPRESS;Initial Catalog=E-commerce;Integrated Security=True;User Id=Anoop Password=anoop@123;Pooling=False">
   providerName="System.Data.SqlClient" />
   </add></connectionstrings>
	<system.web>
    <authentication mode="Forms" />
    <anonymousidentification enabled="true" />
    <profile automaticsaveenabled="false">
      <properties>
        <add name="Id" type="int" allowanonymous="true" />
        <add name="Name" type="String" allowanonymous="true" />
        <add name="ImageUrl" type="String" allowanonymous="true" />
        <add name="Price" type="int" allowanonymous="true" />
        <add name="Item" type="int" allowanonymous="true" />
      </properties>
    </profile></system.web>

推荐答案

在哪里查询将数据存储在数据库表。配置文件用于存储有关页面的个性化信息。
Where is the Query to store the data in the database table. Profile is used to store the personalized information regarding the page.


这篇关于关于将数据存储到asp.net配置文件的问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆