.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

How to change data format in result coming from SQL table

Posted By:      Posted Date: October 18, 2010    Points: 0   Category :ASP.Net

On one of my webpage i am displaying datalist in which i am using this label:

<asp:Label ID="nameLabel12a" runat="server" Text='<%# Eval("CreatedOn") %>' />

This label is displaying created on date along with time (10/18/2010 2:45:07 PM), but i would like to display it something like this:

7sec ago

20min ago

30min ago

23 hours ago

10/3/2010 (if the time is more than 24 hours then it should display the date)

how to accomplish this ? please guide me...

View Complete Post

More Related Resource Links

How to insert values into my table the data is coming from inline table valued function

Hi all,   i have table oi want insert values into my table the data is coming from inline table valued function how i can use the inline table valued function to insert datainto my table i have inline function which out puts 3 collumns of data how i can insert this data into my table i have the insert statment like below insert into tablename(c1,c2,c3,c4,c5) select ('abc',....................,'xyz') how i can use the out put put of my inline function to  to insert data into my columns c2,c3,c4. please help me out Thanks & Regards Sunil Yoganna

How to insert dynamic data into an XML or HTML format table


Hi there,

I have a technical problem as the title described. I need to achieve this by SSIS that means the destination file could be XML or HTML. However, before inserting dynamic data from source, an XML or HTML format table must be predefined. In the final destination file, the predefined table and dynamic data will be both output.

Can anybody give some suggestions or reference links regarding to this? Appreciate it.


Checkboxes from data table


I have a data table that contains some values for Certifications.  This table can be updated in a different part of my application.  On the web page I am currently working on, I would like to have check boxes appear for every value in the data table.  I have been struggling with this trying to use a For Each loop and I cannot get it to work for anything.  Any suggestions? 

I am using the following Razor syntax to obtain my data (I know this works because I can display it in a WebGrid):


var db = Database.Open("MyConn");

How to get data from table based on four table



I need to know how to show top 30 records from four table

with fastest speed.. in ms sql server 2005..

hope You do the needfull


Data Points: Deny Table Access to the Entity Framework Without Causing a Mutiny


Julie Lerman shows database administrators how to limit access to databases from the Entity Framework by allowing it to work only with views and stored procedures instead of tables-without impacting application code or alienating developers.

Julie Lerman

MSDN Magazine August 2010

Data Points: Windows Azure Table Storage - Not Your Father's Database


Let go of your traditional relational database thinking if you want to understand how Windows Azure Table storage works, says Julie Lerman. Luckily for you, she's done the hard work to grasp the new concepts and help you get up to speed.

Julie Lerman

MSDN Magazine July 2010

Under the Table: Visualizing Spatial Data


In this article, the author shows you three new arrivals on the SQL Server spatial visualization scene: the map control in SQL Server 2008 R2 Reporting Services (SSRS), the ESRI MapIt product, and the MapPoint Add-In for SQL Server 2008.

Bob Beauchemin

MSDN Magazine November 2009

Under the Table: How Data Access Code Affects Database Performance


In this article, the author delves into some commonly used ways of writing data access code and looks at the effect they can have on performance.

Bob Beauchemin

MSDN Magazine August 2009

Under The Table: Spatial Data Support In SQL Server 2008


New spatial data support in SQL Server 2008 opens the door to mapping and querying geometric and geographic data, allowing you to build exciting new applications.

Bob Beauchemin

MSDN Magazine February 2009

Data Points: Common Table Expressions


In T-SQL, views and derived tables serve similar purposes and have their advantages. But when working with SQL Server 2005,there's a third option--using Common Table Expressions (CTEs). John Papa explains.

John Papa

MSDN Magazine October 2007

Table format of RadioButtonList


Hi All,

I have radiobuttonlist with 3 listItem, i need to give the table format to radiobuttonlist means it looks like table with row, how can i give, Any idea?

My code:-

<asp:RadioButtonList ID="RbAccount" runat="server" cssClass="Request">
<asp:ListItem Value="update" Selected="True">Change existing account </asp:ListItem>
<asp:ListItem Value="deprovision">Remove an account </asp:ListItem>
<asp:ListItem Value="new" Enabled="false">Create a new account </asp:ListItem>

If i am using this css style, it is giving me border all all the tables i have on page, i just want only this radiobuttonlist, Any idea ?

<style type="text/css">
    border:1px solid black;

Change data on gridview bind


Hi there,

Simple little problem. i have a gridview that shows products assigned to a customers job. They are displayed in exVAT prices. To make it easier i want to show the inc VAT prices. How can i add VAT to 1 column in this table?

How can I change the color of my clandar by data from Db

Sub DayRender(ByVal source As Object, ByVal e As DayRenderEventArgs)

            Dim i As Integer
            For i = 0 To DataGrid1.Items.Count - 1
            'If (DataGrid1.Items(i).Cells(1).Text = e.Day.Date) Then
            'If (DataGrid1.Items(i).Cells(0).Text <> "") Then
            If (DataGrid1.Items(i).Cells(1).Text.Equals(e.Day.Date.ToString)) Then

                '  e.Cell.BackColor = Color.DarkOrange
                e.Cell.BackColor = System.Drawing.Color.Red
                e.Cell.ForeColor = System.Drawing.Color.Yellow

            End If
now I click the day on clendar, which have data from db it chage color ,  How can I let when the calendar is load wich day have dat in db change color ?

    End Sub


change calendar date backColor base on data from db


I want to  change calendar date backColor base on data from db,  I only have vistual 2003 !

on mean time I have

<asp:DataGrid id="DataGrid1" style="Z-INDEX: 102; LEFT: 23px; POSITION: absolute; TOP: 271px"
		    runat="server" Font-Size="XX-Small" Font-Names="Verdana" AutoGenerateColumns="False" Visible="False">
           <asp:BoundColumn DataField="subject" HeaderText="Title"></asp:BoundColumn>
           <asp:BoundColumn DataField="posttimestart" HeaderText="Post date"></asp:BoundColumn>


Sub DayRender(ByVal source As Object, ByVal e As DayRenderEventArgs)
        Dim i As Integer
        For i = 0 To DataGrid1.Items.Count - 1
            If (DataGrid1.Items(i).Cells(1).Text = e.Day.Date) Then
                e.Cell.BackColor = Color.DarkOrange

            End If

    End Sub

when I click the day wich have data in db it change  color , but I want the page load it change color !

Thank you!

Change grid view from table to other HTML layout



You'll have to excuse my ignorance, I'm coming at this from a front-end perspective, and don't really know how to deal with data views in ASP.NET.

Basically, I'm trying to change the layout of some repeated data from a straight table, to something more design-heavy.  It's the same data, just re-organised slightly.  The current ASP.NET code looks like this:

                    <asp:GridView ID="GVMoments" runat="server" AllowPaging="True" AllowSorting="True"
                        AutoGenerateColumns="False" PageSize="20" RowHeaderColumn="FirstName"
                        SkinID="GroupSkin" DataKeyNames="moment_id" 
                        <PagerSettings Mode="NumericFirstLast" PageButtonCount="20" Position="TopAndBottom" />
                        <RowStyle />
                                <asp:BoundField DataField="moment_id" HeaderText="moment_id" ReadOnly="True" SortExpression="moment_id"
                                    Visible="False" In

need your help regarding table and database.. without data lose



I have a table like this in database

ItemNo ItemName Qty  

001       A               50       

002       A               20      

003       B               50  

004       C               60      

005       D               40 

006       E               90      

upto it has some 3000 rows in table..

Now what my problem is i have one more field in mydevelopment PC let us consider another column Category

I need to update this column to my client pc without losing 3000 data from table which already exist...

How to do...?

Entity Data Model and database view returning the same columns as there are in a table


When adding a stored procedure into the Entity Data Model I can select whether the procedure returns a scalar, a (new) complex type or one of the entity types I already defined. 

How do I do something similar for a view?

I mean assuming I have a view like this

CREATE VIEW FilteredFoos as SELECT Foo.* FROM Foo join ... WHERE ...

(that is a view that implements some involved filtering, but returns all columns from one table) how do I add it to the project so that I can use the entity set, but get the Foo objects, not some new FilteredFoo objects.

var foos = myDB.FilteredFoos.Include("Bar").ToList();

foreach (Foo foo in foos) { ...

Thanks, Jenda

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend