HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlMinor

Genetically engineered doodle creatures selector combo

Submitted by: @import:stackexchange-codereview··
0
Viewed 0 times
selectorcreaturescombodoodleengineeredgenetically

Problem

I have created an awesome cheat/fan page for the game Doodle Creatures with the help of some cool people in The 2nd Monitor. Is there anything I can do to improve this code?

Here is my ASP.NET markup:

```
' SelectCommand="SELECT [Animal1].[AnimalImage] AS AnimalImage1, [Animal2].[AnimalImage] AS AnimalImage2,
[Animal1].[AnimalImageAltText] AS AltText1, [Animal2].[AnimalImageAltText] AS AltText2,
[Animal1].[AnimalImageToolTip] AS ToolTip1, [Animal2].[AnimalImageToolTip] AS ToolTip2,
[Animal2].[GroupID] AS Animal2Group,
[Genes].[GeneImg], [Genes].[GeneAltText], [Genes].[GeneToolTip] FROM [CreatureCombos]
INNER JOIN [Animals] AS Animal1
ON [CreatureCombos].[NewCreatureID] = Animal1.[AnimalId]
INNER JOIN [Animals] AS Animal2
ON [CreatureCombos].[ComboAnimalID] = Animal2 .[AnimalId]
INNER JOIN [Genes] ON [CreatureCombos].[ComboGeneID] = [Genes].[GeneId]
ORDER BY AltText2;">
' SelectCommand="SELECT [Animal1].[AnimalImage] AS AnimalImage1, [Animal2].[AnimalImage] AS AnimalImage2,
[Animal1].[AnimalImageAltText] AS AltText1, [Animal2].[AnimalImageAltText] AS AltText2,
[Animal1].[AnimalImageToolTip] AS ToolTip1, [Animal2].[AnimalImageToolTip] AS ToolTip2,
[Genes].[Gene],
[Genes].[GeneImg], [Genes].[GeneAltText], [Genes].[GeneToolTip] FROM [CreatureCombos]
INNER JOIN [Animals] AS Animal1
ON [CreatureCombos].[NewCreatureID] = Animal1.[AnimalId]
INNER JOIN [Animals] AS Animal2
ON [CreatureCombos].[ComboAnimalID] = Animal2 .[AnimalId]
INNER JOIN [Genes] ON [CreatureCombos].[ComboGeneID] = [Genes].[GeneId]
WHERE @ByComboGene = [Genes].[Gene]
ORDER BY AltText2;">




' SelectCommand="SELECT [Animal1].[AnimalImage] AS AnimalImage1, [Animal2].[AnimalImage] AS AnimalImage2,
[Animal1].[AnimalImageAltText] AS AltText1, [Animal2].[AnimalImageAltText] AS AltText2,
[Animal1].[AnimalImageToolTip] AS ToolTip1, [Animal2].[AnimalImageToolTip] AS ToolTip2,
[Animal2].[GroupID],

Solution

First thing that I would do is to create stored procedures for your select statements so that you don't clutter up your aspx pages. This will look a lot nicer and allow you to change the query without having to recompile the website.

I am just scanning right now, but you could also populate your DropDownLists with a SQLDataSource, something similar to



I wasn't sure exactly what the datatextfield and the datavaluefield should be, so make sure you change those to be what you need them to be.

Code Snippets

<asp:dropdownlist id="DropDownList1" 
      runat="server" 
      datasourceid="SQL_FilterByComboGene"
      datatextfield="AltText1" 
      datavaluefield="AltText1"
      CssClass="BigText" 
      AutoPostBack="true">
</asp:dropdownlist>

Context

StackExchange Code Review Q#78172, answer score: 3

Revisions (0)

No revisions yet.