大家好。我正在为cms工作 [英] hi gud eve to all. i am working for cms
本文介绍了大家好。我正在为cms工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在为cms工作,其中所有页面都是动态创建的,因为我已经将所有标题从数据库返回到菜单条,现在当我点击页面时i..e标题它有从数据库获取内容,其中所有这些都包含在数据库的一个表中i..e我如何动态地重定向到该页面。为此我已经为它写了一个
i am working for cms in which the all the pages are created dynamically now the thing is that i have get back all the title from database to the menu strip, now when i click on the page i..e title it has to get content from database where all this contain in the one table of the database i..e how i can redirect to that page dynamically.for this i have written a for it
public partial class menu : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
PopulateMenu();
}
DataSet GetMenuData()
{
SqlConnection con = new SqlConnection("Data Source=localhost;Initial Catalog=newdata23;User ID=sa;Password=123");
SqlDataAdapter dadCats = new SqlDataAdapter("SELECT cms_title FROM cms", con);
//SqlDataAdapter dadProducts = new SqlDataAdapter("SELECT * FROM Products", con);
DataSet dst = new DataSet();
dadCats.Fill(dst, "cms");
return dst;
}
public void PopulateMenu()
{
DataSet dst = GetMenuData();
foreach (DataRow masterRow in dst.Tables["cms"].Rows)
{
MenuItem masterItem = new MenuItem((string)masterRow["cms_title"]);
Menu1.Items.Add(masterItem);
}
}
}
推荐答案
请参考链接:
1) Link1
2) Link2
这篇关于大家好。我正在为cms工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文