Thursday, November 27, 2008

deneme 1 2

Monday, November 24, 2008

Loading Images Asynchronously Inside a GridView

1) Add a template field for gridview.

<asp:TemplateField>

<HeaderTemplate>Picture</HeaderTemplate>

<ItemTemplate>

<img border="1" src="images/cursor.jpg" onerror="this.src=images/error.jpg" onload="RetrievePicture(this,'<%# Eval("pic_id")%>');"/>

</ItemTemplate>

</asp:TemplateField>

2) Javascript function to call.

<script type="text/javascript" language="javascript">

function RetrievePicture(imgCtrl, picid)

        {

            imgCtrl.src = 'ShowImage.ashx?id=' + picid;

        }

</script>

Consuming .net webservices with Jquery in JASON format.

1) Add [ScriptService] attribute to your webservice.

2) Call your method with JQuery. Very Simple!

$.ajax({
type: "POST",
url: "ServiceName.asmx/WebMethodName",
data: "{'parameter1':'p1','parameter2':'p2'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(msg) {
// Do
 stuff
}
});

Technorati Tags: ,,,,

Thursday, November 6, 2008

SQL Server: Peer-to-Peer Transactional Replication

It is often necessary to have the same database running in multiple servers. With transactional replication, several instances of the same database can run in completely different servers and communicate to each other. All the insert, update, delete operations are synced between the databases.

An application can benefit from peer-to-peer replication in the following ways:

    • Improved read performance, because reads are spread out over two or more servers.
    • Higher availability if maintenance is required or in case of failure at one server.

Read More:
http://msdn.microsoft.com/en-us/library/ms151196.aspx

Cool!, So how can I configure this? Here is the link:

Configuration with SQL Management Studio

 

Tuesday, November 4, 2008

Resize Bitmap C#

public Bitmap ResizeBitmap(Bitmap b, int width, int height)
{
Bitmap result = new Bitmap(width, height);
using (Graphics g = Graphics.FromImage((Image)result))
g.DrawImage(b, 0, 0, width, height);

return result;
}

Resetting the identity number in SQL Server.

DBCC CHECKIDENT ('tablename', RESEED,1)

Thursday, August 16, 2007

USE Database
SELECT ColumnName
FROM Table
Group BY ColumnName
Having count(*) > 1

Monday, August 6, 2007

Copy a table from one database to another

There are many ways to copy a database table to an another database. Below you will find the simplest solution I found for myself.

SELECT *
INTO TargetDatabase.dbo.MyTable
FROM SourceDatabase.dbo.MyTable

del.icio.us Tags: ,,

Thursday, July 19, 2007

ASP GridView: Displaying the Summary Data in the Footer

It is many times necessary to display some additional data in the GridView's footer row. This task can be accomplished through the RowDataBound event handler.

protected void Gridview_RowDataBound(object sender, GridViewRowEventArgs e)
{
         if (e.Row.RowType == DataControlRowType.Footer) //if the row is footer
         {
                e.Row.Cells[3].Text = "Some text" ;
         }
}

del.icio.us Tags: ,,,

Tuesday, May 15, 2007

identity ID of the inserted row with TableAdapter.Insert()

Simple solution:

Select MAX(xxxID) From xxxTable