newbie--datalist question

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default newbie--datalist question

    I have the ASP Unleased book--of course all code. So it doesn't help me tie
    it to the VSNET IDE easily--to know what I have to do and what is done for
    me.

    I am trying to make a simple datalist that will get 3 fields from a database
    plus the Identity field--so 4 total--identity field won't be shown.

    I dropped a datalist on the webform.. Found the Edit Template menu
    item...went into edit template mode..
    I dragged some Web forms controls in each of the various templates. I set
    style background colors etc.

    In this design form all three controls (webform labels) are on one line, but
    the show up with a large amount of space between each item (vertically)
    Why?
    I do have an edititem template that is larger and has multiple lines, but I
    thought that that only mattered when it was to do an edit.

    I made a linkbutton Edit in the ItemTemplate

    I set its commandname to edit

    in my book he had to do a OnEditCommand=dlstAuthors_EditCommand in his
    example...
    with the IDE, I don't have to do that or do I.

    I am connecting to SQL in code not through a sqlconnection control--does
    that matter?

    Due to this I had to go into my HTML code and place the text='<%#
    container.dataitem("whatever")%>
    Manually. Should I have done it this way... Is there a way to do that in
    the IDE? Or will it only work if there is a SQL Connection control on the
    form? What is the best way?

    Anyhow in the datalist1_editcommand sub
    I placed
    datalist1.edititemindex=e.item.itemindex
    binddatalist 'this just hits the sql server for the data

    But click edit didn't bring up the edit item as I had imagined.

    Can anyone tell me why my formatting for each item has all this vertical
    space between items, but in the template I see no reason why?

    And why doesn't my edit command work?

    Thanks



    SStory Guest

  2. Similar Questions and Discussions

    1. Datalist question
      I'm using a datalist with Repeat Column = 2.. Which will be Rendered <TR> <TD></TD> <TD></TD> </TR> now i want to add horizontal seprator.. I...
    2. Newbie:Access custom Itemplate(not datagrid/repeater/datalist) control values on postback
      Newbie:Access custom Itemplate(not datagrid/repeater/datalist) control values on postback Hi, I have simple Itemplate implementation with 2...
    3. Problem using dynamic Datalist templates - Newbie
      Hi there! Hopefully somebody can help as I am getting desperate. I am using C# to develope a web user control containing a DataList and I want...
    4. DataList Control Formatting Question
      Hi I have a Datalist control and am using it to display some data (snippet below). Sometimes there is no record for, say, "Mobile". In this...
    5. Design Question -- DataList, Probably Easily Answered
      Hi Ron, Check out this article: http://www.developer.com/net/asp/article.php/2215041 I think it will get you going in the right direction. ...
  3. #2

    Default Re: newbie--datalist question

    SStory,
    >In this design form all three controls (webform labels) >are on one
    line, but
    >the show up with a large amount of space between each item
    >(vertically)
    >Why?
    You should look at the HTML to figure out the formatting.
    >in my book he had to do a >OnEditCommand=dlstAuthors_EditCommand in his
    >example...
    >with the IDE, I don't have to do that or do I.
    Contrary to the opening pages of any beginner book, the drag'n'drop
    features of the IDE will not take you very far. The
    OnEditCommand=dlsAuthor_EditCommand is what associates Edit clicks
    within the DataList with an event handler, in this case Sub
    dlsAuthors_EditCommand (bottom of page 539).

    The SQLConnection control on the form is a simple way to have the IDE
    write some of you code for you. There are a bunch of different ways to
    connect to a db. Whatever works, works.

    To make the edit work, you have to have CommandName="edit" in the
    control, "OnEditCommand = dlsAuthor_EditCommand" in the DataList, and
    "datalist1.edititemindex=e.item.itemindex" within the sub routine,
    making sure that the datalist1 value is the same as the name of your
    datalist (dlstAuthors in the book).

    I hope this helps,
    Barry

    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    Barry Guest

  4. #3

    Default Re: newbie--datalist question

    Thanks for the answers Barry.

    So this means if I had placed a SQL connection on the form it would have done this for me, but since I connected by code I have to do the On command statements in HTML..

    Here's the code(on down below).. Why does it space so far apart between each item ( I added the pre tags to show the code in html emailer)?

    what I want for example is

    Edit Nashville, TN 30105
    Edit Camden, AL 30306
    should be simple

    Then the edit form would be bigger like
    City [text box]

    State [drop down]

    Zip [text box]
    Update Delete Cancel

    Any how it looks more like
    Edit Nashville, TN 30105




    Edit Camden, AL 30306
    <pre> <asp:datalist id="dlstRepAvailLocations" runat="server" height="124px">
    <selecteditemtemplate>
    <asp:label id="Label20" runat="server" width="76px" text='<%# Container.dataitem("rploc_City")%>'>
    </asp:label>,&nbsp;
    <asp:label id="Label21" runat="server" width="33px" text='<%# Container.dataitem("rploc_State")%>'>
    </asp:label>&nbsp;
    <asp:label id="Label22" runat="server" text='<%# Container.dataitem("rploc_ZipCode")%>'>
    </asp:label>
    </selecteditemtemplate>
    <itemtemplate>
    <asp:linkbutton id="lnkEdit" runat="server" commandname="edit">Edit</asp:linkbutton>
    <asp:label id="lblDLCity" runat="server" width="76px" text='<%# Container.dataitem("rploc_City")%>'>
    </asp:label>,
    <asp:label id="lblDLState" runat="server" width="33px" text='<%# Container.dataitem("rploc_State")%>'>
    </asp:label>&nbsp;
    <asp:label id="lblDLZipCode" runat="server" text='<%# Container.dataitem("rploc_Zipcode")%>'>
    </asp:label>
    </itemtemplate>
    <alternatingitemtemplate>
    <asp:linkbutton id="lnkEditAlt" runat="server" commandname="edit">Edit</asp:linkbutton>&nbsp;
    <asp:label id="Label17" runat="server" width="76px" text='<%# Container.dataitem("rploc_City")%>'>
    </asp:label>,
    <asp:label id="Label18" runat="server" width="33px" text='<%# Container.dataitem("rploc_State")%>'>
    </asp:label>&nbsp;
    <asp:label id="Label19" runat="server" text='<%# Container.dataitem("rploc_ZipCode")%>'>
    </asp:label>
    </alternatingitemtemplate>
    <edititemtemplate>
    <p>
    <asp:label id="Label23" runat="server" width="68">City</asp:label>
    <asp:textbox id="txtEditCity" runat="server" width="115px" text='<%# Container.dataitem("rploc_City")%>'>
    </asp:textbox>
    <asp:requiredfieldvalidator id="Requiredfieldvalidator1" runat="server" cssclass="VALERRMSG" errormessage="City Required"></asp:requiredfieldvalidator><br>
    <asp:label id="Label24" runat="server" width="69">State</asp:label>
    <uc1:states id="States1" runat="server"></uc1:states><br>
    <asp:label id="Label25" runat="server" width="69px">Zip Code</asp:label>
    <asp:textbox id="txtEditZipCode" runat="server" width="70px" text='<%# Container.dataitem("rploc_City")%>'>
    </asp:textbox>
    <asp:requiredfieldvalidator id="Requiredfieldvalidator5" runat="server" cssclass="VALERRMSG" errormessage="Zip Code Required"></asp:requiredfieldvalidator></p>
    <p align="center">
    <asp:linkbutton id="lnkUpdate" runat="server" commandname="update">LinkButton</asp:linkbutton>&nbsp;|
    <asp:linkbutton id="lnkDelete" runat="server" commandname="delete">Delete</asp:linkbutton>&nbsp;|
    <asp:linkbutton id="lnkCancel" runat="server" commandname="cancel">Cancel</asp:linkbutton></p>
    </edititemtemplate>
    </asp:datalist></pre>

    At first I was using grid layout but then switched and threw this datalist into a table cell on the left side.
    I have project I need to do within a month--pretty big--I really need to figure this and datagrids out.
    Probably work similar.

    Thanks in Advance,

    Shane


    "Barry" <barrygilbert@nospam.com> wrote in message news:#fbLnD5WDHA.1940@TK2MSFTNGP10.phx.gbl...
    > SStory,
    >
    > >In this design form all three controls (webform labels) >are on one
    > line, but
    > >the show up with a large amount of space between each item
    > >(vertically)
    > >Why?
    >
    > You should look at the HTML to figure out the formatting.
    >
    > >in my book he had to do a >OnEditCommand=dlstAuthors_EditCommand in his
    > >example...
    > >with the IDE, I don't have to do that or do I.
    >
    > Contrary to the opening pages of any beginner book, the drag'n'drop
    > features of the IDE will not take you very far. The
    > OnEditCommand=dlsAuthor_EditCommand is what associates Edit clicks
    > within the DataList with an event handler, in this case Sub
    > dlsAuthors_EditCommand (bottom of page 539).
    >
    > The SQLConnection control on the form is a simple way to have the IDE
    > write some of you code for you. There are a bunch of different ways to
    > connect to a db. Whatever works, works.
    >
    > To make the edit work, you have to have CommandName="edit" in the
    > control, "OnEditCommand = dlsAuthor_EditCommand" in the DataList, and
    > "datalist1.edititemindex=e.item.itemindex" within the sub routine,
    > making sure that the datalist1 value is the same as the name of your
    > datalist (dlstAuthors in the book).
    >
    > I hope this helps,
    > Barry
    >
    > *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    > Don't just participate in USENET...get rewarded for it!
    SStory Guest

  5. #4

    Default Re: newbie--datalist question



    The SQL Connection method has no impact on whether or not you have to
    use OnCommand. These HTML-based handlers are required regardless.

    I noticed a couple of <p> tags in your editItemTemplate. If you need a
    line break, try removing them or replacing them with <br> tags.

    Barry

    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    Barry Guest

  6. #5

    Default Re: newbie--datalist question

    That is surprising I would have thought that an IDE would do that sort of
    redundant stuff for you.

    My edititem is fine, except it won't appear, just shows the header above the
    datalist and blanks out the datalist... ?

    buy my itemtemplate has no br's but still has a ton of space between each
    item.. I cannot see why.

    Thanks

    "Barry" <barrygilbertusaATyahoo.com> wrote in message
    news:#EFfStBXDHA.2524@TK2MSFTNGP09.phx.gbl...
    >
    >
    > The SQL Connection method has no impact on whether or not you have to
    > use OnCommand. These HTML-based handlers are required regardless.
    >
    > I noticed a couple of <p> tags in your editItemTemplate. If you need a
    > line break, try removing them or replacing them with <br> tags.
    >
    > Barry
    >
    > *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    > Don't just participate in USENET...get rewarded for it!

    SStory Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139