Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Stuck with Datagrid and its HTML output formatting......

Stuck with Datagrid and its HTML output formatting......

Scheduled Pinned Locked Moved ASP.NET
questionhtmldatabasedockerhelp
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    Infernojericho
    wrote on last edited by
    #1

    Hi there, I have a question which has got me stuck for the past couple of days. My question is related to datagrids and HTML. I am well aware how datagrid works and data is retreived. I create the database connection, then pass the data to a dataset, on the HTML side I use the Databinder to display the data. I use the template column for higher customization. Here's an example: <asp:datagrid id.....=""> <columns> asp:templatecolumn <itemtemplate> <table> <tr><td><%# DataBinder.Eval(Container.DataItem,"DATATOBESHOWN") %></td></tr> </table> </itemtemplate> </asp:templatecolumn> </columns></asp:datagrid> The data will be shown in the following format: DATA1 DATA2 DATA3 DATA4 DATA5 DATA6 However, what I want to do is something like this: DATA1 DATA2 DATA3 DATA4 DATA5 DATA6 My point is, I need the next DATATOBESHOWN to be displayed on the right of the just-retreived DATATOBESHOWN, not on the next line. Can it be done? It seems it is the basic HTML properties that wouldn't allow me to do it. Anyone has any ideas? I tried placing the TABLE tags outside the Datagrid tags. No luck. Any clues in what I should do?

    A 1 Reply Last reply
    0
    • I Infernojericho

      Hi there, I have a question which has got me stuck for the past couple of days. My question is related to datagrids and HTML. I am well aware how datagrid works and data is retreived. I create the database connection, then pass the data to a dataset, on the HTML side I use the Databinder to display the data. I use the template column for higher customization. Here's an example: <asp:datagrid id.....=""> <columns> asp:templatecolumn <itemtemplate> <table> <tr><td><%# DataBinder.Eval(Container.DataItem,"DATATOBESHOWN") %></td></tr> </table> </itemtemplate> </asp:templatecolumn> </columns></asp:datagrid> The data will be shown in the following format: DATA1 DATA2 DATA3 DATA4 DATA5 DATA6 However, what I want to do is something like this: DATA1 DATA2 DATA3 DATA4 DATA5 DATA6 My point is, I need the next DATATOBESHOWN to be displayed on the right of the just-retreived DATATOBESHOWN, not on the next line. Can it be done? It seems it is the basic HTML properties that wouldn't allow me to do it. Anyone has any ideas? I tried placing the TABLE tags outside the Datagrid tags. No luck. Any clues in what I should do?

      A Offline
      A Offline
      Ashish Sehajpal
      wrote on last edited by
      #2

      GRID is supposed to work in TABULAR format... you are asking about the COLUMNAR format and that is not possible with GRID (HTML doesn't apply magic) use DATALIST with repeatcolumn=3 to generate such output.... ask freely if you need any help :-D cheers !

      Ashish Sehajpal

      I 1 Reply Last reply
      0
      • A Ashish Sehajpal

        GRID is supposed to work in TABULAR format... you are asking about the COLUMNAR format and that is not possible with GRID (HTML doesn't apply magic) use DATALIST with repeatcolumn=3 to generate such output.... ask freely if you need any help :-D cheers !

        Ashish Sehajpal

        I Offline
        I Offline
        Infernojericho
        wrote on last edited by
        #3

        Thank you thank you thank you thank you!!!! I just can't believe it is that simple, I never quite figured out the difference between Datagrid and Datalist. Now I guess I do. I hope you wouldn't mind me asking another question. It's on textbox and labels. How do you create a "multiline" label? I tried using a textbox, and disabling the borders to make it look like a label, and to set it read only. However I've ran into several issues: The scrollbar is a problem, as it gives others the impression its a textbox after all, I managed to hide the scrollbar with the help of CSS. But this brings another problem: The number of rows in a textbox is fixed. So there is a problem with text longer than the textbox themselves, since I have disabled the scrollbar so users can't scroll, meaning they are unable to read the latter part of the text. I eventually thought of setting the number of rows in the textbox dynamically by getting the length of the string, divide it by the number of characters in each row on the textbox. So if the string to be displayed is like 100 characters long, and my textbox displays 10 characters per line. I do something like: textbox.Rows = string.length / 10. It's not perfect, though. BIG PROBLEM: There is a problem if there are carriage returns (Enters) in the text itself? Let's say if the user types "enter" twice at the 11th character, Basically there should be spaces from character 12 to 30. However when determining the string length does not see the 2 carriage returns as 18 spaces. Therefore it still sets the textbox as 10 rows, although the text takes up 12 rows. I am absolutely stuck in how I should solve this. Can anyone help?

        A 1 Reply Last reply
        0
        • I Infernojericho

          Thank you thank you thank you thank you!!!! I just can't believe it is that simple, I never quite figured out the difference between Datagrid and Datalist. Now I guess I do. I hope you wouldn't mind me asking another question. It's on textbox and labels. How do you create a "multiline" label? I tried using a textbox, and disabling the borders to make it look like a label, and to set it read only. However I've ran into several issues: The scrollbar is a problem, as it gives others the impression its a textbox after all, I managed to hide the scrollbar with the help of CSS. But this brings another problem: The number of rows in a textbox is fixed. So there is a problem with text longer than the textbox themselves, since I have disabled the scrollbar so users can't scroll, meaning they are unable to read the latter part of the text. I eventually thought of setting the number of rows in the textbox dynamically by getting the length of the string, divide it by the number of characters in each row on the textbox. So if the string to be displayed is like 100 characters long, and my textbox displays 10 characters per line. I do something like: textbox.Rows = string.length / 10. It's not perfect, though. BIG PROBLEM: There is a problem if there are carriage returns (Enters) in the text itself? Let's say if the user types "enter" twice at the 11th character, Basically there should be spaces from character 12 to 30. However when determining the string length does not see the 2 carriage returns as 18 spaces. Therefore it still sets the textbox as 10 rows, although the text takes up 12 rows. I am absolutely stuck in how I should solve this. Can anyone help?

          A Offline
          A Offline
          Ashish Sehajpal
          wrote on last edited by
          #4

          use <BR /> for a line break dear. like you have text string as given below aknjdmsdfmdn mnknmdkjd,v cmvlmf,mjjk nbh kj kk jm kj k mkj km k kl kn lvk m,v mhj n, k jk m,h use this line break tag wherever you want, like aknjdmsdfmdn mnknmdkjd,<br />v cmvlmf,mjjk nbh kj kk <br />jm kj k mkj<br /> km k<br /> kl kn lvk m,v<br /> mhj n, k jk m,h it's done..... hope it helps...

          Ashish Sehajpal

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups