Posts Tagged instructions

Formview Control: Binding to Datasources (Getting Started With Simple Ways and Codebehind)


The formview control has several ways of binding(linking) data to it. I will briefly describe a couple of ways to do this and list some resources I found helpful.  Getting started using the formview is not tough…. check it out!!!


Simple Way to Add a Formview and Link Data to it

Adding a formview by using the toolbox in Microsoft Visual Studio

Adding a formview by using the toolbox in Microsoft Visual Studio

First, you need to add a formview to your page by dragging and dropping it from the toolbox on the right in Microsoft Visual Studio.  In the toolbox it is in the data section.(yellow circle above) Drag and Drop it on your page….


Here is where you can start to enable paging.

Here you can bind a datasource to the formview.

Next, switch to Design view (Pink Circle Above) in Microsoft Visual Studio.  Then click on the little tab (green arrow above) on the right of your formview.  From there you click on the drop down list next to Choose Data Source: Then a wizard starts up and you fill in all the information about the connection and what data you want…. You then have a formview with all the trimmings.  [Note: If you have trouble with information for the connection wizard...i.e.- connection username, server name, password... try to ask your hosting service]

 


Binding Data to the Formview Using CodeBehind

Here I will show you one method I have used in codebehind to bind data to my formview. This is a LINQ to SQL sample using VB.NET…. I think the other steps would be different but assigning the datasource and the bind method[Lines L7&L8] would be the same regardless of how you connect to your database. Connect to the database and bind!!!

L1: Dim db As New Blog_InfoDataContext
L2: Dim query2 = From BlogEntries In db.Blog_Entries _
L3: Where DateAdd(DateInterval.Hour, 14, Now()) >= BlogEntries.Start_Date _
L4: Select BlogEntries.ID, BlogEntries.Start_Date, BlogEntries.End_Date, _
L4: BlogEntries.Series, BlogEntries.Unit, BlogEntries.Additional_Comments _
L5: Order By Start_Date Descending
L6:
L7: FormView1.DataSource = query2
L8: FormView1.DataBind()

You can run this code in any event like (Page_Load, Etc.)


Other Links

FormView Control: Step by Step – This one seems to cover most of the the basic topics that are associated with the formview control.


Tags: , , , , , , , ,

Adding Line Breaks <br /> With WordPress

Overview of the Problem

What a difficult chore…. I use WordPress 2.8.6 but apparently this has been an issue with earlier versions of WordPress as well.  I noticed that there was no button to add line breaks.  Further when I tried to add them either in the visual viewer by pressing return or in the HTML viewer by adding <br />…… I could but it was later erased by the editor.  This was very frustrating because line breaks, returns, carriage, returns, or whatever you want to call them are essential to typing.  How was this overlooked?  I am not sure but I needed a solution.

The Answer

I began to search for answers….. I found some solutions but the one that worked for me was using a Plugin called “TinyMCE Advanced“.  This plugin gives you more options for your wordpress editor.  I am speaking of the interface you use to add posts.  The plugin gives you more buttons and options on that interface.  Once you have it installed (Plugins >> Add New) on your version of Wordpress follow these instructions.

1. Go to Settings and choose TinyMCE Advanced

2. At the bottom there is an advanced box.  One of the Check boxes says:

Stop removing the <p> and <br /> tags when saving and show them in the HTML editor

Check this box….

 

Problem solved… You can also add a number of other buttons.  I am currently using TinyMCE Advanced Version 3.2.4….

Here is  a link which gives some other suggestions(tricks with <p> tags) that do not involve plugins…. It is also where I got my idea to use the TinyMCE Plugin…. The other solutions I could not get to work properly but maybe one of them would be better for you.  Most of the suggestions can be found in the comments at the bottom of this post:

How to Add Extra Line Breaks in WordPress


Tags: , , , , ,

WordPress Permalinks: Getting It Right Using Windows

Finding the Right Terminology

When I first started thinking about this topic I was just surfing the web and I began to notice URLs that looked strange to me. These URLs did not list a file name.  I wondered how that could be. Examples look like:

http://dotnetofasp.net/howtoblog/2009/12/wordpress/how-to-setup-wordpress/

http://www.ikailo.com/94/url-modrewrite-workaround-iis-60/

No Filenames for post slugs / permalinks

No Filenames for post slugs / permalinks


Etc. and so on.

It took me a really long time to even know how to search for something like this.  I had no idea what this technique was called.  I searched things like “blog directories”  “weblog, no file names”  “SEO, Blogs”.  Mostly I thought that since this technique is helpful in getting your page found by search engines, I could find it on an SEO site.  As you can guess these searches returned things unrelated to what I wanted.

Finally, a bright idea… Look for a forum about blogging,  a forum about just writing a blog…. I signed up at this forum called Blogging Tips.  I put up a post and the nice British chap that runs the site was quick to respond.  Seems like a pretty good forum thus far.  This forum could help you understand how to make money on your blog but for me it answered the question above.

The name given to this technique is post slugs.  Later while searching I found another name, permalinks.  From here on out I will use the two words interchangeably.  Finally I had put a name (a couple names actually >>> permalinks and post slugs) to what I wanted but how could I use them?  How could I set up my own permalinks?


Windows and ISS Hosting Problems, Errors, Nightmares, Other Bad Words

With some reading I soon learned that my Windows hosting was not setup to handle permalinks.  For some odd reason this was not supported.  I emailed my hosting company(ixwebhosting) for some advice but was assured that it could not be done.  This was after I sent several ideas I had gotten from the WordPress website.  They talk extensively on how to use permalinks. Take a look at the section entitled “Permalinks without mod_rewrite“.  The options listed there include:

1.  Microsoft’s URL Rewrite Module

2.  PATHINFO Permalinks

3.  Custom 404 Redirects

The man from my hosting company that I talked to said it was not possible.

Well……………………………drum roll………………………………………………………………it can be done……. and I did it…………………..actually I just followed the advice of a great programmer so really I did little but copy but you can do the same…..  I used custom 404 redirects.  Below are links on how to get your permalinks working.  I have also listed some other links in case you want to do this a different way.

New Version of a 404 redirect << The link I used

Another Technique Using An isapi-rewrite 3.0 from helicontech.com << Found in this article

Allows for a real 404 page in addition to permalinks



So following the link’s suggestions I created a file to handle the 404 page not found error (wp-404-handler.php). Then I set my hosting to pickup this error and direct all 404 events to wp-404-handler.php. It works perfectly but since it has been three years since this solution, I feel like there could be a better way somewhere out there…. Still it works!!!

Tags: , , , , , , , ,