Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Maintain a list of movie categories. Use a drop-down combo box to hold the movie

ID: 3758624 • Letter: M

Question

Maintain a list of movie categories. Use a drop-down combo box to hold the movie types, keeping the list in alphabetic order. Use buttons or menu choices to Add a Category, Remove a Category, Clear All Categories, Print the Category List, Display the Movie Category Count, and Exit. Include appropriate access keys on your form and/or menu items.

Do not allow a blank type to be added to the list. Display an error message if the user selects Remove without first selecting a movie category. Before clearing the list, display a message box to confirm the operation.

The starting categories are • Comedy • Drama • Action • Sci-Fi • Horror

Display the printed output in the Print Preview dialog box. Include your name and a heading at the top of the report.

Explanation / Answer

using Grid view controllers in ASP.net so i can example for this message using visual studio2012

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
using System.Configuration;

public partial class GridviewEdit : System.Web.UI.Page
{
SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["myconn"]);
static string newSortDirection = "DESC";
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
bindgrid("Select * from dbo.Temp");
}
  
}

public void bindgrid(String Query)
{
SqlDataAdapter adp = new SqlDataAdapter(Query, con);
DataSet ds = new DataSet();
adp.Fill(ds);
grdedit.DataSource = ds.Tables[0];
grdedit.DataBind();
}

public int Executenonquery(String Query)
{
if (con.State == ConnectionState.Closed) con.Open();
SqlCommand cmd = new SqlCommand(Query,con);
return cmd.ExecuteNonQuery();
  
}

protected void grdedit_SelectedIndexChanged(object sender, EventArgs e)
{
String test = grdedit.SelectedRow.Cells[2].Text;
Response.Write("<Script>alert('Select Changed" + test + "')</script>");
}
protected void grdedit_Sorting(object sender, GridViewSortEventArgs e)
{
string sortExpression = e.SortExpression;
bindgrid("Select * from dbo.Temp order by " + sortExpression + " " + ConvertSortDirectionToSql(newSortDirection));
}

private string ConvertSortDirectionToSql(string sort)
{
switch (sort)
{
case "DESC":
newSortDirection = "ASC";
break;
case "ASC":
newSortDirection = "DESC";
break;
}
return newSortDirection;
}


protected void grdedit_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
Response.Write("<Script>alert('Pageing Index Changing:Please Save your Transctions and then Change')</script>");
grdedit.PageIndex = e.NewPageIndex;
bindgrid("Select * from dbo.Temp");
  
}


protected void grdedit_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
{
String Data = grdedit.Rows[e.NewSelectedIndex].Cells[2].Text + ", " + grdedit.Rows[e.NewSelectedIndex].Cells[3].Text + ", " + grdedit.Rows[e.NewSelectedIndex].Cells[4].Text;
Response.Write("<Script>alert('Select Changing"+Data+"')</script>");

}
protected void grdedit_PageIndexChanged(object sender, EventArgs e)
{
Response.Write("<Script>alert('Pageing Index Changed')</script>");
}
protected void grdedit_RowCommand(object sender, GridViewCommandEventArgs e)
{
//we can use this when we do not use command arguments where event will not be as GridViewCommandEventArgs just as EventArgs
//GridViewRow gvr = (GridViewRow)((Control)e.CommandSource).NamingContainer;
//int rowIndex = gvr.RowIndex;
int rowIndex = Convert.ToInt32(e.CommandArgument.ToString());
if (e.CommandName == "Deleteitem")
{
String Value = grdedit.Rows[rowIndex].Cells[2].Text;
Response.Write("<Script>alert('Row Command Event for Delete Item you can handle in another popup or modelpopup with the Item value :"+Value+"')</script>");
  
}
if (e.CommandName == "Updateitem")
{
String Value = grdedit.Rows[rowIndex].Cells[2].Text;
Response.Write("<Script>alert('Row Command Event for update Item you can handle in another popup or modelpopup with the Item value :" + Value + "')</script>");
}
}
protected void btnupdate_Click(object sender, EventArgs e)
{
Button btn = (Button)sender;
String CommandArgment=btn.CommandArgument;
String CommandName=btn.CommandName;
GridViewRow gvRow = (GridViewRow)(sender as Control).Parent.Parent;
int index = gvRow.RowIndex;
String Value = grdedit.Rows[index].Cells[2].Text;
Response.Write("<Script>alert('Update or delete operations by both (1.DataKet and command Arguments,2.Gridviewrow) for paticular id:" + Value + "where Command Argment=" + CommandArgment + "and Command Name=" + CommandName + "')</script>");
}
protected void btnupdate_Click1(object sender, EventArgs e)
{
Button btn = (Button)sender;
string[] CommandArgument = btn.CommandArgument.Split(',');
string CommandArgument1 = CommandArgument[0];
string CommandArgument2 = CommandArgument[1];
string CommandArgument3 = CommandArgument[2];
Response.Write("<Script>alert('Update or delete operations by multiple arguments Vehical Id:" + CommandArgument1 + " Name:" + CommandArgument2 + " Speed:" + CommandArgument3+ "')</script>");
}
  
protected void grdedit_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
String Data = grdedit.Rows[e.RowIndex].Cells[2].Text;
int i=Executenonquery("Delete from Temp where ID=" + Data);
if (i > 0)
bindgrid("Select * from dbo.Temp");
else
{
Response.Write("<Script>alert('Error')</script>");
}

}
protected void grdedit_RowEditing(object sender, GridViewEditEventArgs e)
{
grdedit.EditIndex = e.NewEditIndex;
bindgrid("Select * from dbo.Temp");
}
protected void grdedit_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
{
grdedit.EditIndex = -1;
bindgrid("Select * from dbo.Temp");
}
protected void grdedit_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
int Id = int.Parse(grdedit.Rows[e.RowIndex].Cells[2].Text);
TextBox textVehID = grdedit.Rows[e.RowIndex].Cells[3].Controls[0] as TextBox;
TextBox textLogId = grdedit.Rows[e.RowIndex].Cells[4].Controls[0] as TextBox;
TextBox textLatId = grdedit.Rows[e.RowIndex].Cells[5].Controls[0] as TextBox;
TextBox textSpeed = grdedit.Rows[e.RowIndex].Cells[6].Controls[0] as TextBox;
TextBox textdateOf = grdedit.Rows[e.RowIndex].Cells[7].Controls[0] as TextBox;
grdedit.EditIndex = -1;
int i = Executenonquery("update Temp set VehID='" + textVehID.Text + "',LogId='" + textLogId.Text + "',LatId='" + textLatId.Text + "',Speed='" + textSpeed.Text + "',dateOf='" + textdateOf.Text + "' where id=" + Id.ToString());
if (i > 0)
bindgrid("Select * from dbo.Temp");
else
{
Response.Write("<Script>alert('Error')</script>");
}
}
protected void grdedit_RowCreated(object sender, GridViewRowEventArgs e)
{

}
protected void grdedit_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
string item = e.Row.Cells[2].Text;
foreach (Button button in e.Row.Cells[12].Controls.OfType<Button>())
{
if (button.CommandName == "Delete")
{
button.Attributes["onclick"] = "if(!confirm('Do you want to delete " + item + "?')){ return false; };";
}
}
if (Convert.ToInt32(e.Row.Cells[6].Text) == 0)
{
e.Row.BackColor = System.Drawing.Color.Cyan;
}
}   
}
protected void lnkmdelete_Click(object sender, EventArgs e)
{
foreach (GridViewRow gvrow in grdedit.Rows)
{

CheckBox chkdelete = (CheckBox)gvrow.FindControl("ckgrd");
if (chkdelete.Checked)
{
int usrid = Convert.ToInt32(grdedit.DataKeys[gvrow.RowIndex].Value);
int i = Executenonquery("Delete from Temp where ID=" + usrid);
if (i > 0)
bindgrid("Select * from dbo.Temp");
else
{
Response.Write("<Script>alert('Error')</script>");
}
}
}
bindgrid("Select * from dbo.Temp");
}

  
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote