الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

دورة Asp.net ::: الدرس الرابع ::: شرح الادوات الجزء الثالث

بدأه islamicnfo_a في 4 أغسطس 2009 · 2 رد · 1,087 مشاهدة · في ASP.NET
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

بسم الله الرحمن الرحيم

استكمال لدورة

ASP.NET

اليكم الدرس الثاني الذي نقوم في بشرح الادوات الخاصة بـ

ASP.NET

نشرح في هذا الدرس

DropDownList :::

ListBox :::

و الخصائص لكل اداة

رابط الدرس

http://www.safasoft.ps/alshamel/asp_course/4/

لتحميل الدرس

http://www.safasoft.ps/alshamel/asp_course/4/4.zip

الدرس السابق

اخوكم ::: م. احمد محمد بركات

تم تعديل هذه المشاركة بواسطة islamicnfo_a في 4 أغسطس 2009 في 18:06

arab-code-logo.png

---------------------------

ليست المشكلة أن تخطــىء ، حتى لوكان خطئك جسيما

وليست الميزة أن تعترف بالخطـــأ وتتقبل النصح .. إنمـا

العمل الجبــار الذي ينتظرك حقا هو أن لا تعـــــــــــــود

للخطـــــــأ أبــدا ……

#2
islamicnfo_a كتب:

بسم الله الرحمن الرحيم

استكمال لدورة

ASP.NET

اليكم الدرس الثاني الذي نقوم في بشرح الادوات الخاصة بـ

ASP.NET

نشرح في هذا الدرس

DropDownList :::

ListBox :::

و الخصائص لكل اداة

رابط الدرس

http://www.safasoft.ps/alshamel/asp_course/4/

لتحميل الدرس

http://www.safasoft.ps/alshamel/asp_course/4/4.zip

الدرس السابق

اخوكم ::: م. احمد محمد بركات

اخي العزيز

انا جربت درسك مفيدة جدا

بس عندي مشكلة في صفحة التحديث . اذا لن تختار الصورة ما يسوي تحديث و هذا هو الكود ارجو المساعدة

Server Error in '/NewsWebSite2012' Application.

--------------------------------------------------------------------------------

Procedure or function 'AddEditNews' expects parameter '@NewsImage', which was not supplied.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.Data.SqlClient.SqlException: Procedure or function 'AddEditNews' expects parameter '@NewsImage', which was not supplied.

Source Error: 





Line 65:         cmd.Parameters.AddWithValue("@CatID", CatID);
Line 66: 
Line 67: return cmd.ExecuteNonQuery(); Line 68:     }
Line 69:

my Stored Procedure code is like below ,: , according to it in update case ... when i didn't choose any picture it should use the old picture .. but its not work and show the same error above ..

 ALTER PROCEDURE AddEditNews
(
@NewsID int,
@NewsTitle nvarchar(120),
@NewsDetails nvarchar(max),

@NewsImage image,
@CatID int
)
AS
	if (@NewsID = -1)

	insert into tblNews 
	(NewsTitle,NewsDetails,NewsDate,NewsImage,CatID)
	Values
	(@NewsTitle,@NewsDetails,GetDate(),@NewsImage,@CatID)

	else

	Update tblNews set
	NewsTitle=@NewsTitle, NewsDetails=@NewsDetails,NewsImage= isnull(@NewsImage,NewsImage)
	where
	NewsID=@NewsID

And my DataAccess.cs code is like below :

 public int AddEditNews(string NewsID,string NewsTitle, string NewsDetails, byte[] NewsImage , string CatID)
    {
        SqlCommand cmd = new SqlCommand("AddEditNews", conn);
        cmd.CommandType = CommandType.StoredProcedure;


        cmd.Parameters.AddWithValue("@NewsID", NewsID);
        cmd.Parameters.AddWithValue("@NewsTitle", NewsTitle);
        cmd.Parameters.AddWithValue("@NewsDetails", NewsDetails);
        cmd.Parameters.AddWithValue("@NewsImage", NewsImage);
        cmd.Parameters.AddWithValue("@CatID", CatID);

        return cmd.ExecuteNonQuery();
    }

And the Code behinde the insert and update page is like blow

 public partial class Admin_AddEditeNews : PageDataAccess
{
    protected void Page_Load(object sender, EventArgs e)
    {


        if (!IsPostBack)
        {

            ddlNewsCatagory.DataSource = DA.GetAllNewsCatagory();
            ddlNewsCatagory.DataBind();

            if (Request.QueryString["NewsID"] != null)
            {
                DataTable dt = DA.GetNews(Request.QueryString["NewsID"].ToString());
                txtNewsTitle.Text = dt.Rows[0]["NewsTitle"].ToString();
                txtNewsDetails.Text = dt.Rows[0]["NewsDetails"].ToString();
                ddlNewsCatagory.SelectedValue = dt.Rows[0]["NewsID"].ToString();

                // to get the photo we need to create a separate page holding the codes.

                ThumbImage.Visible = true;
                ThumbImage.ImageUrl = "../Admin/GetImageFromDB.aspx?w=120&NewsID=" + Request.QueryString["NewsID"];

                btnAddNews.Text = "Update News";


            }
        }


    }
    protected void btnAddNews_Click(object sender, EventArgs e)
    {
        //check the fupNewsImage control for if file exist and its image ..
        //first we need to create an array for imae name it imageByte.

        byte[] imageByte = null;
        if (fupNewsImg.HasFile)
        {
            if (fupNewsImg.PostedFile.ContentType.Contains("image"))
            {
                imageByte = new byte[fupNewsImg.PostedFile.ContentLength];
                fupNewsImg.PostedFile.InputStream.Read(imageByte, 0, imageByte.Length);

            }
            else
            {
                lblStatusMsg.Text = "The File which you browsed is not photo....";
                // if itsnot image so no need to go further ... go back to previous code

                return;


            }

        }


        if (btnAddNews.Text.Equals("Add News"))
        {

            if (DA.AddEditNews("-1", txtNewsTitle.Text, txtNewsDetails.Text, imageByte, ddlNewsCatagory.SelectedValue) > 0)
            {

                lblStatusMsg.Text = "The News has been Successfully added";
                txtNewsTitle.Text = txtNewsDetails.Text = "";

            }


        }
        else
        {
            if (DA.AddEditNews(Request.QueryString["NewsID"], txtNewsTitle.Text, txtNewsDetails.Text, imageByte, ddlNewsCatagory.SelectedValue) > 0)
            {

                lblStatusMsg.Text = "The News has been successuly updated....";
                Response.Redirect("ViewDeleteNews.aspx");
            }

        }
    }
}
#3

الرابط لا يعمل

مواضيع مشابهة

عدد الزوار حالياً

المتواجدون خلال آخر دقيقتين · يتحدّث كل ٣٠ ثانية

—الإجمالي—أعضاء مسجّلون—زوار بدون تسجيل

جارٍ التحقق من المتواجدين…