datagrid codebehind formatting

Ask a Question related to ASP.NET Data Grid Control, Design and Development.

  1. #1

    Default Re: datagrid codebehind formatting

    What if columns are not boundColumns?

    "Teemu Keiski" <joteke@aspalliance.com> escribió en el mensaje
    news:eQZRrOYDEHA.1604@TK2MSFTNGP11.phx.gbl...
    > If columns are BoundColumns,. you can specify the format to the
    > DataFormatString property of the column for example: "{0:dd/MM/yyyy}"
    >
    > --
    > Teemu Keiski
    > MCP, Microsoft MVP (ASP.NET), AspInsiders member
    > ASP.NET Forum Moderator, AspAlliance Columnist
    >
    >
    > "mark" <mark@remove.com> wrote in message
    > news:xFV5c.601$K51.463@newsfe1-win...
    > > how do i format datetime in codebehind ?
    > > i use a dll with all my funtions in and the dates are coming out as
    > > 15/03/2004 00:00:00
    > > code is like this :-
    > >
    > >
    > > Function AdminNotSubmitted(ByVal Datagrid As
    > > System.Web.UI.WebControls.DataGrid, ByVal Title As String)
    > >
    > > Dim conn As New System.Data.SqlClient.SqlConnection(SQLstrConn)
    > >
    > > Dim sql As String = "blah"
    > >
    > > Dim da As New System.Data.SqlClient.SqlDataAdapter(sql, conn)
    > >
    > > Dim ds As DataSet = New DataSet()
    > >
    > > da.Fill(ds)
    > >
    > > ds.Tables(0).Columns.Item(0).ColumnName = "ID "
    > >
    > > ds.Tables(0).Columns.Item(1).ColumnName = "Surname "
    > >
    > > ds.Tables(0).Columns.Item(2).ColumnName = "Mge Admin "
    > >
    > > ds.Tables(0).Columns.Item(3).ColumnName = "Date To Mge Admin "
    > >
    > >
    > >
    > > Datagrid.DataSource = ds.Tables(0)
    > >
    > > Datagrid.DataBind()
    > >
    > > Title = "blah"
    > >
    > > Return ds.Tables(0).Rows.Count()
    > >
    > > End Function
    > >
    > >
    > > thanks
    > >
    > > mark
    > >
    > >
    >
    >

    Miguel Ramirez Guest

  2. Similar Questions and Discussions

    1. Datagrid Formatting
      I am trying to find out if it is possible to format a datagrid to display results in teh following manner; Job: 5453 South Ridge Lane ...
    2. Formatting a datagrid
      Hi, I am working on my first web app that uses a datagrid. I can't seem to find good examples of formatting the grid the way you can in a Windows...
    3. Datagrid SelectedIndexChanged Problem in CodeBehind
      I am attempting to use the SelectedIndexChanged to detect when a row has been selected. I have seen many examples where they are writing all the...
    4. Print asp:datagrid with formatting
      Hi I need to Print asp:datagrid with formatting, which will avoid my writing of crystal reports and can directly print with click of a button. ...
    5. datagrid paging - codebehind
      are you setting the button column to CommandName=Select in the ASP page? "Bent Kjeldsen" <news@nospam.dithjem.dk> wrote in message...
  3. #2

    Default Re: datagrid codebehind formatting

    > What if columns are not boundColumns?
    do the same thing in the itemdatabound event handler except that you would
    use the cell variable
    e.item.cells[0].text =
    DateTime.Parse(e.item.cells[0].text).tostring("dd/MM/yyyy);

    roughly (i wouldn't bet on this compiling but the idea is sound)

    --
    Regards,
    Alvin Bruney
    [ASP.NET MVP [url]http://mvp.support.microsoft.com/default.aspx][/url]
    Got tidbits? Get it here... [url]http://tinyurl.com/27cok[/url]
    "Miguel Ramirez" <miguel.ramirez@valycontrol.com.mx> wrote in message
    news:%234ZlR76NEHA.620@TK2MSFTNGP10.phx.gbl...
    > What if columns are not boundColumns?
    >
    > "Teemu Keiski" <joteke@aspalliance.com> escribió en el mensaje
    > news:eQZRrOYDEHA.1604@TK2MSFTNGP11.phx.gbl...
    >> If columns are BoundColumns,. you can specify the format to the
    >> DataFormatString property of the column for example: "{0:dd/MM/yyyy}"
    >>
    >> --
    >> Teemu Keiski
    >> MCP, Microsoft MVP (ASP.NET), AspInsiders member
    >> ASP.NET Forum Moderator, AspAlliance Columnist
    >>
    >>
    >> "mark" <mark@remove.com> wrote in message
    >> news:xFV5c.601$K51.463@newsfe1-win...
    >> > how do i format datetime in codebehind ?
    >> > i use a dll with all my funtions in and the dates are coming out as
    >> > 15/03/2004 00:00:00
    >> > code is like this :-
    >> >
    >> >
    >> > Function AdminNotSubmitted(ByVal Datagrid As
    >> > System.Web.UI.WebControls.DataGrid, ByVal Title As String)
    >> >
    >> > Dim conn As New System.Data.SqlClient.SqlConnection(SQLstrConn)
    >> >
    >> > Dim sql As String = "blah"
    >> >
    >> > Dim da As New System.Data.SqlClient.SqlDataAdapter(sql, conn)
    >> >
    >> > Dim ds As DataSet = New DataSet()
    >> >
    >> > da.Fill(ds)
    >> >
    >> > ds.Tables(0).Columns.Item(0).ColumnName = "ID "
    >> >
    >> > ds.Tables(0).Columns.Item(1).ColumnName = "Surname "
    >> >
    >> > ds.Tables(0).Columns.Item(2).ColumnName = "Mge Admin "
    >> >
    >> > ds.Tables(0).Columns.Item(3).ColumnName = "Date To Mge Admin "
    >> >
    >> >
    >> >
    >> > Datagrid.DataSource = ds.Tables(0)
    >> >
    >> > Datagrid.DataBind()
    >> >
    >> > Title = "blah"
    >> >
    >> > Return ds.Tables(0).Rows.Count()
    >> >
    >> > End Function
    >> >
    >> >
    >> > thanks
    >> >
    >> > mark
    >> >
    >> >
    >>
    >>
    >
    >

    Alvin Bruney [MVP] 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