Problems with the CreateUserWizard

May 21, 2009 at 2:57 PMJeffery

The problem I had was that no matter what I did it would not take me to the next step that I had. I finally found the answer but took me many  hours of looking, so I thought I would share this.

Actually the fix is very easy and this problem happens when using the CssFriendly Control Adapters. And the fix it to comment or delete out of the CssFriendlyAdapters.browser file the entry for the CreateUserWizard control.

 

i hope this helps someone as I wasted a lot of time on this problem.

 

Thanks,

JefferyS

Posted in: ASP.NET 2.0+ | Programming

Tags:

DropDownList inside a DetailsView, how to databind

May 12, 2009 at 9:10 AMJeffery

It's been far to long sense I blogged. Sorry about that.

An application I'm programming has a DetailsView with a DropDownList inside. I had a lot of trouble getting this to work so I thought that I would share this information to make it easier for someone else.

This may not be the best way but it seams to work ok. A lot of articles I've read about this use some sort of datasource in the aspx page. I thought the idea was to separate presentation from the business logic so I try to stay away from that.

Basically you have a DetailsView like this (I've removed a lot of extra code and left the important code to make it less confusing):

<asp:DetailsView ID="dvItem" runat="server" CssClass="detailsView" DataKeyNames="ItemIdPkey"  onDataBound="dvItem_DataBound">
    <HeaderTemplate>
            Title
    </HeaderTemplate>
        <Fields>
            <asp:TemplateField HeaderText="Category">
                <ItemTemplate>
                    <asp:Label ID="lblCategory" runat="server" Text='<%# Bind("ItemCategoryName") %>'></asp:Label>
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:DropDownList ID="ddlCategory" runat="server">
                    </asp:DropDownList>
                </EditItemTemplate>
                <InsertItemTemplate>
                    <asp:DropDownList ID="ddlCategory" runat="server">
                    </asp:DropDownList>
                </InsertItemTemplate>
            </asp:TemplateField>
</Fields>
</asp:DetailsView

 The necessary parts are the onDataBound event and having the DropDownList in an Edit or insert template.

Of course you would have all the other events that go with editing, inserting, mode changing, etc...

Now for the C# code:

protected void dvItem_DataBound(object sender, EventArgs e)
{
    if (this.dvItem.CurrentMode == DetailsViewMode.Edit)
    {
        DropDownList ddlCategory = (DropDownList)this.dvItem.FindControl("ddlCategory");
        if (ddlCategory != null)
        {
             DataTable dt = ItemCategory.ItemCategorySelectAll().Tables[0];
             ddlCategory.DataSource = dt;
             ddlCategory.DataTextField = "itemCategoryName";
             ddlCategory.DataValueField = "itemCategoryId_Pkey";
             ddlCategory.DataBind();

             WishListItem li = (WishListItem)this.dvItem.DataItem;
             ddlCategory.Items.FindByValue(li.ItemCategoryFkey.ToString()).Selected = true;
           }
     }

}

 This is only showing the edit mode code but the Insert code would be about the same except for the finding of the value to make it selected. The last two lines should be deleted.

 I also found that when accessing the DataItem you need to use the type of datasourse that you gave it. In this I have a class WishListItem that was the datasourse. If you used a DataTable or DataSet then you would assign that to the DataItem. Hope that made sense.

If you have any questions please let me know.

Thanks,

Jeffery

 

 

Posted in: ASP.NET 2.0+ | C# | Programming | DetailsView

Tags:

Visual Studio 2008 Error List pops up a lot in webforms code view

February 19, 2009 at 4:42 PMJeffery

There are some things about Visual Studio 2008 that annoy me. One of the worst ones is when you'll be typing away in code view on an asp.net page and the Error List bounces up and down. The cause of this is the page validator you have set and when it finds a asp.net control or HTML control or a css class that it can't find or is not valid it pops up the Error List. Also when using Themes the IDE in code view doesn't seam to see the style sheets you have. So when typing away setting the Id of a label control or something the Error List jumps up and down when you arrow or mouse away form what you were just typing.  I hope this makes sense. I have looked for a solution and found some people just disabling the validator. Hiding the Error List does nothing because it keeps coming back. So while trying to see what I could do I right clicked on the error list and there it was   an option, that are on a lot of  little windows in the IDE, to set the Error List as a Tabbed Document!

I can handle that being a tab with the rest of my documents. So no more bouncy Error List to get in the way or annoy me. And If I need to look at the list of errors and warning I just click on the tab.

I know this isn't all that exciting but it helps me concentrate on the programming and not watching the Error List flash on the screen.

 

Sometimes it's the little things in life that makes us happy.

 

JefferyS

Posted in: Programming | Visual Studio 2008

Tags:

Code Reuse - Making your own Project Templates

December 7, 2008 at 3:21 PMJeffery

It seams making a Project Template is easier than I thought.

There is a very good article here that explains the process.

Seeing that, I started thinking that I could make several project templates for my Data Access web sites, or a template that has all the membership, roles, and profiles setup. Actually for that I could make several versions of web.config template with that stuff in it too.

When ever I create a site I am always adding a site map, master page, style sheet, Javascript libraries, and other things. That would make a great project template to have all that in there all ready for me to work with. You could also add all the different folders that you might use on a regular bassis. Script, Images, Styles, Themes, and other folders.

This is very exciting. I should have looked up how to do this long ago.

Anyway that's all I have for right now.

Take Care,

JefferyS

Posted in: ASP.NET 2.0+ | C# | JavaScript | Programming

Tags:

Code Reuse

November 19, 2008 at 10:21 AMJeffery

I've been very bad at keeping up on my blogging but here is another one.

I am very bad a Code Reuse. Mostly because I haven't found a good way to keep track of things. So I'm always writing the same code over and over.

The other day I was creating a style sheet in visual studio and I thought, "dummy you should make an item template for this style sheet because you always start with the same code".

I have never created an Item Template so I looked it up. It's very easy to do. You can get real complex and project templates are more involved. This morning when I received my ASP101 newsletter, there it was. A tip on how to create a Visual Studo Item Template.

So no need for me to explain it again when someone else did a fine job of saying it. But as a simple example you can take the current StyleSheet Item Template and make one of your own.

Here is what is in the StyleSheet provided by Visual Studio 2008.

body {

}

Not much to it. so lets add a few things that may be used a lot in a style sheet.

body {

    margin:0px; font-family: Tacoma, Arial; font-size:12px;

}

a {

    text-decoration:none;

}

a:hover {

    text-decoration:underline;

}

So now when you open your customized StyleSheet Item Template you have a lot more done and setup. Depending on your projects you could make style sheets for different page layouts .

Just a simple thing to do, but it will save you some time not having to cut and paste from another file.

You can do this with classes, asp.net pages, master pages, etc..

I'll also look into the project templates to see what's involved. If I can't find a good tutorial then I'll write one.

Thanks,

 

JefferyS

Posted in: ASP.NET 2.0+ | C# | JavaScript | Programming

Tags: