Geeks With Blogs

  • azamsharp The WWDC app says that there are new videos but there is nothing under videos!!! about 682 days ago
  • azamsharp Can I post my opinion on iOS 7 Beta or is it under NDA or something? about 682 days ago
  • azamsharp iOS 7 BETA installed successfully! about 682 days ago
  • azamsharp iOS 7 BETA installed! Now restoring! I am on NET10 which uses AT&T network. Hopefully 3G will still work! Lets c.. about 682 days ago
  • azamsharp The missing of button borders in Xcode 5 makes it hard to determine the clickable area. about 682 days ago
  • azamsharp I might wait for iOS to be released before I can put it on my device! Don't want a bricked or unstable device! about 682 days ago
  • azamsharp Android has many features that no one uses, number of versions that no one upgrades to and thousands of apps that no one pays for. about 682 days ago
  • azamsharp Maybe it is just me but the new iOS 7 UI looks like Windows Phone 8 UI! #maybeIamCrazy about 683 days ago
  • azamsharp Anyone using H20 network upgraded to iOS 7 BETA Keep me updated if you face any problems. about 683 days ago
  • azamsharp @merowing_ You already downloaded it! I cannot even load the developer's website! :( about 683 days ago

AzamSharp Some day I will know everything. I hope that day never comes.

Dynamic Website Project allows you to create customizable support pages. This can be really helpful if part of your job is to create boring support pages. Recently, I had to create few support pages so I thought why not try the Dynamic Website Project. So, I added the LINQ to SQL as the data source and used one of the databases to create the support pages.

In our application whenever a row in the database is updated we update the DateModified field. This can easily be performed inside the GridView_RowUpdating event as shown below (ListDetailsTempate.aspx):

 protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
        e.NewValues["DateModified"] = DateTime.Now;

Now, whenever you update any row the DateModified field wil be modified automatically.

Another thing that I needed to add was the support for choosing multiple databases. If I add a table from a different database to the LINQ to SQL designer then it will use the new database as the primary database and you will not be able to access the old database tables. This is because the connetionString will be overriden and will be pointing to the new database. To fix this issue I created a DropDownList which is populated with all the names of the databases and their respective context classes(The context classes will be the classes automatically generated by the LINQ to SQL).

  <dataContext name = "Exams" type="CasaSupportPages.DatabaseContexts.ExamsDataContext" />
  <dataContext name="Users" type="CasaSupportPages.DatabaseContexts.UsersDataContext" />

Here is the code to populate the DropDownList:

 private void PopulateDropDownList()
            XDocument doc = XDocument.Load(Server.MapPath("~/ContextSettings.xml"));

            foreach (var element in doc.Root.Elements("dataContext"))
                ddlDatabases.Items.Add(new ListItem((string)element.Attribute("name"),(string) element.Attribute("type")));   

Finally, after selecting the correct database you press the button and now your Dynamic Website will be created using the new database.

public static void SetDatabaseContext(string contextType)
            Configuration config = WebConfigurationManager.OpenWebConfiguration("~/");
            ConfigurationSectionGroup group = config.GetSectionGroup("system.web.extensions");
            ConfigurationSection section = group.Sections["dynamicData"];
            PropertyInformation propInformation = section.ElementInformation.Properties["dataContextType"];
            propInformation.Value = contextType;

This way you can create support pages (dynamic pages) using multiple databases.

Posted on Thursday, January 24, 2008 12:25 PM | Back to top

Comments on this post: Using Multiple Databases with the Dynamic Website Project

# web site development
Requesting Gravatar...
hi dary online supportry i need dynamic html code about web site development & together with mysql_db using php code connected.please healp me because iam student& also sick ,but i have aproject.
Left by zinabu alemayehu on May 08, 2008 3:13 AM

# web site development
Requesting Gravatar...
I work in a firm as a web developer. But i want to work web developing at home and want to earns some money. But how can i get work. Plz give me a suggestion.
Left by munna on Jun 23, 2008 11:15 PM

Your comment:
 (will show your gravatar)

Copyright © Mohammad Azam | Powered by: | Join free