How do I: work with related tables on a User Edit Form?

5 posts, 0 answers
  1. Kevin
    Kevin avatar
    7 posts
    Member since:
    Oct 2013

    Posted 20 Nov 2013 Link to this post

    Howdy All,

        Not sure the best forum to post this on, so i'll start here...  I have two questions here...  I have two tables (Settings, and SettingsTypes). One of which (Settings) I'm displaying in a grid.  It has a field (SettingType) that is related to an TypeID field in the SettingTypes table.  Right now I have the grid display the setting and the integer value for it's settingtype field.  I would like to display the related settingtype Name field from the SettingType table.  Any Ideas???



    My second question is I have a User Defined edit page ( settingsDetail) page that is used when the user "edits" a row in the setting table's grid.  the dataitem on that page is the datarow  from the settings table.  I would like to place on the details page a dropdownlist/combobox  of the settingtype names instead of having the user input an integer value.  How do I get to the settingtype table from the datarow from the setting table as the datatitem???  I could not find any decent examples of using the User Control page (my details page)...  I'm going of the example at: http://demos.telerik.com/aspnet-ajax/grid/examples/data-editing/edit-form-types/defaultvb.aspx  but that has only a "Hard Coded" dropdown...  I would like to get the values from a table NOT "Hard Coded".



    As a caveat, I'm a Newbie when it comes to ASP.Net... so bare with me if my questions are a bit basic :-)



    Thanks in advance,

    Kevin Orcutt

    Matson Money, Inc.

    (513) 204-8000 x8245

    (513) 204-8245 (Direct)

    Kevin.Orcutt@MatsonMoney.com

    www.MatsonMoney.com


  2. Steve Lassanske
    Steve Lassanske avatar
    5 posts
    Member since:
    Sep 2007

    Posted 20 Nov 2013 Link to this post

    I'm sorry if I miss understood both of your requests. But your first paragraphs sounds a lot like the Telerik's Master/Detail grids example (http://demos.telerik.com/aspnet-ajax/grid/examples/data-binding/master-detail/defaultcs.aspx).

    Your second paragraph is harder for me to understand, but if you're trying to modify the contents of your settings type dropdown in your settings grid when you edit the setting type in your settings type grid, in the event that fires when you save your setting types you could rebind your settings grid causing your settings type RadComboBox's OnItemsRequested to fire, assuming you're populating your  RadComboBox through some kind of data source. But I suspect you might've meant something else.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Kevin
    Kevin avatar
    7 posts
    Member since:
    Oct 2013

    Posted 20 Nov 2013 Link to this post

    OK, I'll try and clarify... 

    In my first paragraph, I currently have a table (Settings) that has:



    SettingType   SettingName   SettingValue
    1   AJAXTimeOut   600
    2   ProtectedFilePath   C:\websites\ProtectedDownloads


    What I would like to have is:

    SettingType   SettingName   SettingValue
    Integer   AJAXTimeOut   600
    String   ProtectedFilePath   C:\websites\ProtectedDownloads


    The cell values of "Integer" and "String" are from the related table (SettingType)  The ID of 1 and 2 are stored in the Setting Table and also in the SettingType table as well.  With the datasource of the grid set to a datatable with the values from the Setting table.  I would like the grid to display values in a related table not necessary in a Master/Detail scenario....  I do not want to display everything in the second/related table...  just some of the fields, namely the settingtypename ("Integer, String" and so on, not the integer values of 1,2,...)



    Let me think a little bit more on clarifying my second paragraph...  I'll get back on that hopefully tomorrow... :-)



    Thanks again,



    Kevin Orcutt





     

  5. Kevin
    Kevin avatar
    7 posts
    Member since:
    Oct 2013

    Posted 21 Nov 2013 Link to this post

    OK I think I can explain my second paragraph a little better now...  Here's a picture to help:






    As you can see in the grid above the user edit form page you'll see a "2" in the first column, after the "edit" column...  Also on the Details page, you'll also see a "2" in the top textbox...  In my first paragraph, I'm asking on how to display either "Integer" or  "String" in the first cell instead of a "1" or "2", the values of "Integer" and :"String" come from the related table (SettingType)...  Now for my second paragraph... In the User Edit form/detail page...  I would like to have a dropdownlist instead of that first textbox for the SettingType field...  What's stored in the (Setting) table is a "1" or a "2" and so on based on the type, but I would like to have the user choose from more human meaningful values of "Integer", "String", "Boolean" and so on... these values will come from the related table...  As in this particular example, it is my goal to allow the user to go in change the incorrect settingtype of "2" to be the correct type of "1" but have them really choose from the dropdown containing "Integer" , "String" , "Boolean" and what not... 

    So my BIG question is that on the detail page, the dataitem on the page contains the datarow from the settings table, with the SettingType integer field of 1's ,2s,3,s and so on. but I would like to present the user with "The readable values to choose from. which is in the related table... I'm NOT editing the related table, just using values from it for presentation.    So is there an easy way to get to that related table via the dataitem that is a datarow from the main table???? 



    Thanks in advance,



    Kevin Orcutt

  6. Eyup
    Admin
    Eyup avatar
    3005 posts

    Posted 25 Nov 2013 Link to this post

    Hi Kevin,

    You can achieve the requested functionality by using SQL Joins to use the two tables simultaneously:
    http://www.w3schools.com/sql/sql_join.asp
    In your case it would probably look something like:
    <asp:SqlDataSource ID="SqlDataSource1" runat="server"
        ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
        SelectCommand="SELECT * FROM Setting INNER JOIN SettingType ON Setting.TypeID=SettingType.TypeID "></asp:SqlDataSource>

    Having all of the required fields loaded in the grid, you can now use GridDropDownColumn:
    http://www.telerik.com/help/aspnet-ajax/grid-column-types.html#dropdown

    Alternatively, you can use a GridTemplateColumn:
    http://www.telerik.com/help/aspnet-ajax/grid-column-types.html#template

    Thus, you will be able to display the SettingTypeName while actually editing the SettingID.

    Hope this helps.

    Regards,
    Eyup
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017