Compile SQL Table using Dropdown list boxes into TextBox

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rgh3320
    New Member
    • Sep 2012
    • 2

    Compile SQL Table using Dropdown list boxes into TextBox

    I am completely new to SQL server i know a few of the basics. I have a VS2010 asp.net c# application with two dropdown listboxes and a textbox. I need to calculate the numbers e.g 3 + 3 = Medium, using the table below to calculate the answer so i can insert the output value into a textbox. Could anyone please help ?

    Regards Rob


    Table
    1 2 3 4 5
    1 Cold Cold Cold Cold HOT
    2 Cold Cold Cold Medium HOT
    3 Cold Medium Medium HOT HOT
    4 Medium Medium Medium HOT HOT
    5 Medium Medium Medium HOT HOT
    Drop down Listbox 3 Drop down Listbox 3

    TextBox Medium
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    I have no idea what you mean. I don't see how 3 + 3 = medium. Rather it looks like you mean that you're looking up the value in a grid/array. Where 3,3 is the coordinate you want to look up. But that's not what you said so that's only a guess on my part. If that's not what you mean, I don't know this new math that you're using to calculate words.

    Comment

    • rgh3320
      New Member
      • Sep 2012
      • 2

      #3
      Yes it is coming from a grid that i need to lookup. So far i have come up with this but there must be a easier way of doing it and i would if possible to do it all in c#. Sorry i know this is a sql forum.

      Code:
      create table lookup
         (
         rowkey int,
         colkey int,
         display varchar(10)
         )
      
      insert into lookup values (1,1,'Cold')
      insert into lookup values (2,1,'Cold')
      insert into lookup values (3,1,'Cold')
      insert into lookup values (4,1,'Medium')
      insert into lookup values (5,1,'Medium')
      insert into lookup values (1,2,'Cold')
      insert into lookup values (2,2,'Cold')
      insert into lookup values (3,2,'Medium')
      insert into lookup values (4,2,'Medium')
      insert into lookup values (5,2,'Medium')
      insert into lookup values (1,3,'Cold')
      insert into lookup values (2,3,'Cold')
      insert into lookup values (3,3,'Medium')
      insert into lookup values (4,3,'Medium')
      insert into lookup values (5,3,'Medium')
      insert into lookup values (1,4,'Cold')
      insert into lookup values (2,4,'Medium')
      insert into lookup values (3,4,'Hot')
      insert into lookup values (4,4,'Hot')
      insert into lookup values (5,4,'Hot')
      insert into lookup values (1,5,'Hot')
      insert into lookup values (2,5,'Hot')
      insert into lookup values (3,5,'Hot')
      insert into lookup values (4,5,'Hot')
      insert into lookup values (5,5,'Hot')
      
      select display as text_to_display
      where rowkey = @rowkey and colkey = @colkey

      Comment

      • Rabbit
        Recognized Expert MVP
        • Jan 2007
        • 12517

        #4
        That's exactly the way I would do it in SQL. But if this is a static array, then you can just save it as a multidimensiona l array and do it all in C#. Even if it wasn't static, you could still do it in C# by saving off the array. It's just slightly more complicated if it's not static because you have to manage how to save, edit, and read said array.

        Comment

        Working...