This is a migrated thread and some comments may be shown as answers.

Insert, Update, Delete RadListView From Code behind

1 Answer 250 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Rasha
Top achievements
Rank 1
Rasha asked on 09 May 2013, 12:02 PM
Hi to all,
Sorry to bother you with what might seem beginners question, I tried  to use ListView1_ItemCommand to as shown in my code below, but nothing happened the insert command is not firing should I use OnCommandInserting, if there is a form or example on how this could be done I would deeply appreciated.
thanks.
Rasha. 
if (e.CommandName == RadListView.PerformInsertCommandName)
{
    SqlCommand cmd = new SqlCommand();
    try
    {
        SqlConnection con = DataAccess.Connection.GetDBConnection();
        if (con.State == ConnectionState.Closed)
        {
            con.Open();
        }
        cmd.CommandText = "INSERT INTO [Package] VALUES (@PackageName, @PackageDesc, @PricePerMonth, @discountPercent, @NumOfImg, @NumOfGIF, @NumOfFlash, @isHomePageIncluded)";
        cmd.Parameters.Add("@PackageName", SqlDbType.VarChar);
        cmd.Parameters.Add("@PackageDesc", SqlDbType.VarChar);
        cmd.Parameters.Add("@PricePerMonth", SqlDbType.Money);
        cmd.Parameters.Add("@discountPercent", SqlDbType.Float);
        cmd.Parameters.Add("@NumOfImg", SqlDbType.Int);
        cmd.Parameters.Add("@NumOfGIF", SqlDbType.Int);
        cmd.Parameters.Add("@NumOfFlash", SqlDbType.Int);
        cmd.Parameters.Add("@isHomePageIncluded", SqlDbType.Bit);
 
        cmd.Connection = con;
 
        int result = cmd.ExecuteNonQuery();
        con.Close();
    }
    catch (Exception exp)
    {
        Response.Write(exp +"in Command: " + cmd.ToString());
    }

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 10 May 2013, 06:09 AM
Hi Rasha,

Please have a look into this demo which demonstrates Manual Datasource operations such as insert, delete, update with the RadListView Control.

Thanks,
Shinu.
Tags
ListView
Asked by
Rasha
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or