Monday, March 12, 2012

how to Copy Item one Gridview to another gridview

I have Two gridview left side where i populate data from Database and other will be empty at 1st time my requirement is when click any item and click to add button it will remove from that cell and add in to second gridview

same thing happens through drag and drop system Drag from one gridview to another well but it will be helpfull how to remove and add one gridview to another can someone give me idea

bye take care
regards
vikrant

Check out these links

http://forums.asp.net/p/1169459/1955946.aspx

http://www.codeproject.com/KB/HTML/SelectMoveRowsFromTables.aspx

Labels: , , , , , , , , , ,

How to convert time format

Hi all,

I had query some time information from the database and use a dataset to bind to a GridView.

But unfortunately, the time that display on the GridView is not my desired choice.

It was display as "3/1/2007 10:06:27 PM".

Does anyone know how to convert it as "3/1/2007 22:06:27"?

Part of my code is as follow

pgDataAdapter.Fill(ds,

"Start Time");

Thanks

Hi bslim67,

You can use the DataFormatString property of the GridView column to format the datetime value.

Hope this helps.


Hi,

Hi,

I had tried this.

<asp:BoundFieldDataField="starttime"dataformatstring="{0:dd/MMM/yy}"

HeaderText

="Start Time"ReadOnly="True"SortExpression="starttime"/>

But when I run the program during runtime, it seems that it did not take effect.

It still show me the date and time though my dataformat is only on date.

Please help.

Thanks


Dear , friend:

You should set HtmlEncode=false in the markup of:BoundField

I hope the above information will be helpful. If you have any issues or concerns, please let me know. It's my pleasure to be of assistance


Hi,

Thanks for your info. It's really a great help for me.

Labels: , , , , , , , , , , ,

How to convert string data into time format

I have some of the old data looks like this. And this is time data.

144601
170320
083345

I wanted to convert this in proper format as time with AM, PM etc. and display in GridView column.

Currently this data is displaying as it is in one of the GridView column

Please help out..

thanks

Public Function stringtodate(ByVal strdate As String) Dim tempdt As Date tempdt = Convert.ToDateTime(strdate) Dim format1 As String Dim en As New CultureInfo("en-AU") format1 = "MM/dd/yyyy HH:mm:ss" Dim dtstring As String dtstring = tempdt.ToString(format1) tempdt = DateTime.ParseExact(dtstring, format1, en.DateTimeFormat) Return tempdt End Function

you can specify the format as u need.

How do I call this function in gridview, to display the data in one of the column of the grid view. ?


Use Bound column of grid.Now in datafield property try to bind the data using a literal.

<asp:literal id="datevar" runat="server">

<asp:grid>

<asp:boundcolumn ......datafield=<%= datevar %>

</asp:grid>

Now in code behind try to bind the your date value by calling that function to the datevar literal in grid_databound event.

Labels: , , , , , , , ,

How to convert a date field to short date? without time.

I am using a query builder to buld a sql statement which brings me somes fields which are defined as date, and they are brought like this one: 5/17/2006 12:00:00 AM and I just want to bring the 5/17/2006.

I tried

CONVERT (CHAR(10), Fecha_evento, 101) ASFecha_evento

It works, for displaying, but when I try to look for the maximun within that field, it interprets it as a string, so I do not get the right value. Do you have a way to solve this? thanks a lot!

There's really no such thing as a date without a time. If you're having problems with displaying the information on a form, you should look at formatting the value, rather than changing the actual value that's retrieved. Setting your format string to "{0:MM/dd/yyyy}" should format it as you've indicated above.

Labels: , , , , , , , , , , , , , , ,