TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
george wambui
NA
17
39.5k
How do I create a dynamic menu and sub menu in ASP.NET using C#
Mar 28 2012 2:38 AM
hi team,
please help to correct the following code below which i have written but its giving an error of 'ds' and 'ddl' doesnt contain in the context
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Data.Odbc;
public partial class creatmenu : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
FillddlMainMenu();
}
}
public void FillddlMainMenu()
{
OdbcConnection conn = new OdbcConnection("dsn=parcel;uid=dba;pwd=sql");
DataSet dsFill = new DataSet();
OdbcDataAdapter OdbcDa = new OdbcDataAdapter("Select MainMenuId,MainMenu from MainMenu", conn);
conn.Open();
OdbcDataAdapter.Fill(ds);
ddlMainMenu.DataSource = DS;
ddlMainMenu.DataBind();
}
protected void btnMainmenu_Click(object sender, EventArgs e)
{
OdbcCommand cmd;
int active;
if (chkMActive.Checked)
{
active = 1;
}
else
{
active = 0;
}
OdbcConnection conn = new OdbcConnection("dsn=parcel;uid=dba;pwd=sql");
cmd = new OdbcCommand("INSERT INTO mainmenu(mainmenu, mcontent, menuorder,isactive)VALUES('" + txtMainmenu.Text + "','" + txtMContent.Text + "'," + Convert.ToInt16(MOrder.SelectedItem.Value) + "," + active + ")", conn);
conn.Open();
//cmd.CommandType = CommandType.Text;
cmd.ExecuteNonQuery();
conn.Close();
FillddlMainMenu();
Response.Redirect("creatmenu.aspx");
}
protected void btnSubmenu_Click(object sender, EventArgs e)
{
int active;
if (chkSActive.Checked)
{
active = 1;
}
else
{
active = 0;
}
OdbcCommand cmd;
OdbcConnection conn = new OdbcConnection("dsn=parcel;uid=dba;pwd=sql");
cmd = new OdbcCommand("INSERT INTO submenu(submenu, content, menuorder,parentid,isactive)VALUES('" + txtSubmenu.Text + "','" + txtSContent.Text + "'," + Convert.ToInt16(ddlSOrder.SelectedItem.Value) + "," + Convert.ToInt16(ddlMainMenu.SelectedItem.Value) + "," + active + ")", conn);
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
Response.Redirect("creatmenu.aspx");
}
}
regard
george
Reply
Answers (
5
)
Implementation of entity, boundary and control class
Can someone please help me with the code of menu and sub menu in C#