Asp.NET GridView CommandField için OnClientClick Methodu
27 Haziran 2012CommandName'lerinden yakaladığımız ImageButton'lara OnClientClick property sini kullanarak mesaj verdirme işlemi aşağıdaki gibi sonuçlanmakta.
Gönderen Aslı Nurkan Tarikulu zaman: 10:30 0 yorum
Etiketler: ASP.NET-AJAX, Örnekli-Resimli Anlatım, WEB
DataView ilw sqlDataSource dan veri okuma - örnek kod
08 Haziran 2012 sdsS1ASponsor.DataBind();
DataView dv = (DataView)sdsS1ASponsor.Select(DataSourceSelectArguments.Empty);
string RS = "";
for (int i = 0; i < dv.Table.Rows.Count; i++)
{
RS = dv.Table.Rows[i]["Tanim"].ToString();
if (RS == "B1")
{
ltrlB1.Text = dv.Table.Rows[i]["ResimIcerik"].ToString().Replace("<p>", "").Replace("</p>", "");
}
else if (RS == "B2")
{
ltrlB2.Text = dv.Table.Rows[i]["ResimIcerik"].ToString();
}
else if (RS == "B3")
{
ltrlB3.Text = dv.Table.Rows[i]["ResimIcerik"].ToString();
}
else if (RS == "R5")
{
ltrlR5.Text = dv.Table.Rows[i]["ResimIcerik"].ToString().Replace("<p>", "").Replace("</p>", "");
}
}
Asp.Net Kontrollerinde Eval() akışı
09 Aralık 201101.05.2009 tarihinde oğuzhan tarafından yazıldı.
Huh! başlık enteresan oldu ama konu çok enteresan değil. Kendime bir CheetSheet yapayım diyorum hatırlaması kolay olsun diye, neyse konuya girelim..Asp.Net kontrollerini kullanırken DataBinding olayın da, gelen verinin belirli koşullara göre bind olmasını isteyebilirsiniz. Böyle durumlarda Eval() metodunu kullanarak kontrolün istediğimiz özelliğine (attributes) belirli bir koşula göre değer atayabilme ihtiyacımız doğar. Aşağıda Eval() metodu ile nasıl koşul kullanabiliyoruz bildiğim kadarı ile örneklerini veriyorum.
Olayı tam çözmek için
<%# BirSeylerYap(Eval("deger")) %>
private string BirSeylerYap(string Deger)
{
if (Deger.Equals("bune"))
return "beyaz";
else
return "siyah";
}
Kullanışlı bir örnek.<%#Eval("deger").Equals("bune") ? "beyaz" : "siyah"%>
Object türünden.<%#Eval("deger") ?? "beyaz"%>
if..else..else if gibi ise.
<%#Eval("deger").Equals("A") ? "beyaz" :
Eval("deger").Equals("B")? "siyah":
Eval("deger").Equals("C") ? "yesil":
"sari"%>
bu kadar ;)A simple makro in Excel - listing the names of png files in the folder
05 Ekim 2011Sub Makro1()
Dim MyFolder As String, MyFile As String
Dim i As Long
MyFolder = "E:\works\ufuk\ufukAksesuar01\galeri\big\stopper"
MyFile = Dir(MyFolder & Application.PathSeparator & "*.png", vbDirectory)
Do While MyFile <> ""
Cells(i + 1, 1) = MyFile
i = i + 1
MyFile = Dir
Loop
End Sub
SqlDataSource: Getting @@Identity after Insert
14 Temmuz 2011Yesterday I was developing a simple form using a SqlDataSource to INSERT or UPDATE when saving the form. The form consisted of a few controls and a button. In the case of a new item, on clicking the save button I am executing SqlDataSource1.Insert(). For an existing item, I’m using an “ID” parameter on the query string which in turn is used by the UPDATE command. So I need the ID of the row I’ve just inserted to allow the user to update the form. I should mention my table has a column called “ID” of type int which is specified as the auto-incrementing identity column. I put together the form in less than 30 minutes and then spent twice that time trying to find the solution you are reading now. I was sorely tempted to ditch the DataSource as this is straightforward when you’re executing your SQL commands directly in the code-behind. But I was curious and persevered until I found the answer: Firstly, let me describe how to set up the DataSource to do the insert. The InsertCommandType is “Text”. For the InsertQuery click the … button to open the Command and Parameter dialog. Use the query builder, if you like, to create your insert statement. After the insert statement append “SET @Identity = @@Identity;” so our insert command looks something like this: INSERT INTO TestTable (TestCol) VALUES (@TestValue); SET @Identity = @@Identity; The statement above has 2 parameters. One is TestValue we’re setting in to TestCol. The other is Identity which will be the ID of the column we insert. Click Add Parameter and type “TestValue”, Parameter source is control, and ControlID is a textbox. Add another parameter called “Identity”. This time click Show Advanced Properties, set Direction to “Output” and Type to “int” (leaving Parameter source as “None”). Now the trick is catching the DataSource at the right time so that our output parameter will have a value. Don’t mistake the DataSource.InputParameters as the place to look as this merely describes the parameters we’ve configured above. To actually see the parameters after execution you need to catch the OnInsertedevent. Here we have SqlDataSourceStatusEventArgs which contains the command and its parameters after the command has executed. protected void SqlDataSource1_Inserted(object sender, SqlDataSourceStatusEventArgs e) { //Read the value of the @Identity OUTPUT parameter string sID = e.Command.Parameters["@Identity"].Value.ToString(); //Display new ID Label1.Text = sID; } So with the ID known I can now redirect the user to "page.aspx?ID=" + sID such that they may update the form. Alıntıdır...
Gönderen Aslı Nurkan Tarikulu zaman: 13:47 0 yorum
Etiketler: ADO.NET, ASP.NET-AJAX, SQL
FETCH (Transact-SQL) SQL Server 2008
NEXT
- Returns the result row immediately following the current row and increments the current row to the row returned. If FETCH NEXT is the first fetch against a cursor, it returns the first row in the result set. NEXT is the default cursor fetch option.
- PRIOR
- Returns the result row immediately preceding the current row, and decrements the current row to the row returned. If FETCH PRIOR is the first fetch against a cursor, no row is returned and the cursor is left positioned before the first row.
- FIRST
- Returns the first row in the cursor and makes it the current row.
- LAST
- Returns the last row in the cursor and makes it the current row.
- ABSOLUTE { n| @nvar}
- If n or @nvar is positive, returns the row n rows from the front of the cursor and makes the returned row the new current row. If n or @nvar is negative, returns the row n rows before the end of the cursor and makes the returned row the new current row. If n or @nvar is 0, no rows are returned. n must be an integer constant and @nvar must be smallint, tinyint, orint.
- RELATIVE { n| @nvar}
- If n or @nvar is positive, returns the row n rows beyond the current row and makes the returned row the new current row. If n or @nvar is negative, returns the row n rows prior to the current row and makes the returned row the new current row. If n or @nvar is 0, returns the current row. If FETCH RELATIVE is specified with n or @nvar set to negative numbers or 0 on the first fetch done against a cursor, no rows are returned. n must be an integer constant and @nvar must be smallint, tinyint, orint.
- GLOBAL
- Specifies that cursor_name refers to a global cursor.
- cursor_name
- Is the name of the open cursor from which the fetch should be made. If both a global and a local cursor exist with cursor_name as their name, cursor_name to the global cursor if GLOBAL is specified and to the local cursor if GLOBAL is not specified.
- @ cursor_variable_name
- Is the name of a cursor variable referencing the open cursor from which the fetch should be made.
- INTO @variable_name[ ,...n]
- Allows data from the columns of a fetch to be placed into local variables. Each variable in the list, from left to right, is associated with the corresponding column in the cursor result set. The data type of each variable must either match or be a supported implicit conversion of the data type of the corresponding result set column. The number of variables must match the number of columns in the cursor select list.
When the Transact-SQL DECLARE cursor extensions are used, these rules apply:
- If either FORWARD_ONLY or FAST_FORWARD is specified, NEXT is the only FETCH option supported.
- If DYNAMIC, FORWARD_ONLY or FAST_FORWARD are not specified, and one of KEYSET, STATIC, or SCROLL are specified, all FETCH options are supported.
- DYNAMIC SCROLL cursors support all the FETCH options except ABSOLUTE.
A.Using FETCH in a simple cursor
USE AdventureWorks GO DECLARE contact_cursor CURSOR FOR SELECT LastName FROM Person.Contact WHERE LastName LIKE 'B%' ORDER BY LastName OPEN contact_cursor -- Perform the first fetch. FETCH NEXT FROM contact_cursor -- Check @@FETCH_STATUS to see if there are any more rows to fetch. WHILE @@FETCH_STATUS = 0 BEGIN -- This is executed as long as the previous fetch succeeds. FETCH NEXT FROM contact_cursor END CLOSE contact_cursor DEALLOCATE contact_cursor GO
B.Using FETCH to store values in variables
USE AdventureWorks GO -- Declare the variables to store the values returned by FETCH. DECLARE @LastName varchar(50), @FirstName varchar(50) DECLARE contact_cursor CURSOR FOR SELECT LastName, FirstName FROM Person.Contact WHERE LastName LIKE 'B%' ORDER BY LastName, FirstName OPEN contact_cursor -- Perform the first fetch and store the values in variables. -- Note: The variables are in the same order as the columns -- in the SELECT statement. FETCH NEXT FROM contact_cursor INTO @LastName, @FirstName -- Check @@FETCH_STATUS to see if there are any more rows to fetch. WHILE @@FETCH_STATUS = 0 BEGIN -- Concatenate and display the current values in the variables. PRINT 'Contact Name: ' + @FirstName + ' ' + @LastName -- This is executed as long as the previous fetch succeeds. FETCH NEXT FROM contact_cursor INTO @LastName, @FirstName END CLOSE contact_cursor DEALLOCATE contact_cursor GO
C.Declaring a SCROLL cursor and using the other FETCH options
USE AdventureWorks GO -- Execute the SELECT statement alone to show the -- full result set that is used by the cursor. SELECT LastName, FirstName FROM Person.Contact ORDER BY LastName, FirstName -- Declare the cursor. DECLARE contact_cursor SCROLL CURSOR FOR SELECT LastName, FirstName FROM Person.Contact ORDER BY LastName, FirstName OPEN contact_cursor -- Fetch the last row in the cursor. FETCH LAST FROM contact_cursor -- Fetch the row immediately prior to the current row in the cursor. FETCH PRIOR FROM contact_cursor -- Fetch the second row in the cursor. FETCH ABSOLUTE 2 FROM contact_cursor -- Fetch the row that is three rows after the current row. FETCH RELATIVE 3 FROM contact_cursor -- Fetch the row that is two rows prior to the current row. FETCH RELATIVE -2 FROM contact_cursor CLOSE contact_cursor DEALLOCATE contact_cursor GO
Gönderen Aslı zaman: 12:37 0 yorum
Etiketler: Örnekli-Resimli Anlatım, SQL
SQL SERVER’DA VERİLERİ SAYFALAMAK
by Halil İbrahim ARAÇ 27. Eylül 2009 21:57
| select ROW_NUMBER() OVER(ORDER BY SozID) AS RowNumber,* from Sozler |
| select ROW_NUMBER() OVER(ORDER BY SozID desc) AS RowNumber,* from Sozler |
| CREATE proc [dbo].[VERIGETIR] ( @bas int, @son int ) as begin with kayitseti as ( select ROW_NUMBER() OVER(ORDER BY SozID) AS 'RowNumber',* from Sozler ) select * from kayitseti where RowNumber between @bas and @son end |
| exec VERIGETIR 3,8 |
| ALTER proc [dbo].[VERIGETIR] ( @bas int, @son int ) as begin select * from(SELECT ROW_NUMBER() OVER(ORDER BY SozID) AS RowNumber,* FROM Sozler) as kayitseti where RowNumber between @bas and @son end |
Gönderen Aslı zaman: 12:32 0 yorum
Etiketler: Örnekli-Resimli Anlatım, SQL
SQL Server 2008 de Otomatik BackUp için Job Oluşturma (Schedule)
15 Nisan 2010SQL Server üzerinde bulunan Job (Schedule) mantığıyla bir çok işi otomatik olarak SQL Server a yaptırmak mümkün. Bu işlemlerden biride otomatik yedek aldırma. Örneğin bir job tasarlayıp her akşam gece 12.00 da database veya databaselerin yedeğini aldırabiliriz.
Örneğin, SQL Server 2008 üzerinde AdventureWorks databasenin otomatik yedeğini almak için bir job tasarlayalım.
Management Studio >> SQL Server Agent >> Jobs kısmına gelip sağ tık ile New job a geçelim.
General kısmında Name ve istediğiniz bir category i seçtikten sonra Steps kısmına geçiniz.
Steps kısmında bu job için uygulanacak adımlar tanımlanmaktadır. Yani burda birden fazla database in yedeklenmesini farklı adımlar olarak tanımlayabiliriz. Biz bu örneğimiz için sadece tek adım yani AdventureWorks ün yedeklenmesini tanımlayacağız.
Bunun için New butonuna basalım.
Resimde görüldüğü gibi alanları dolduralım. Command kısmında yazan yazı BackUp alma işlemini gerçekleştirecek T-SQL komutudur.
1 | BACKUP DATABASE [AdventureWorks] |
2 | TO DISK = N'c:\\AdventureWorks.bak' |
Gerekli alanların tamamını resimdeki gibi doldurduktan sonra OK e basıp arka ekranda Schedules kısmına gelelim.
Schedules bölümü job un hangi otomatik süreyle işleneceğinin belirleneceği bölümdür. Resimde de görmüş olduğunuz üzere günlük,haftalık,aylık istediğimiz gibi ayarlama yapabilmekteyiz. Biz bu örneğimizde sonucu hızlıca alabilmek açısından dakikada 1 seçeneğini ayarlıyoruz.
Resimde görüldüğü gibi alanları doldurduktan sonra OK e basıp arka ekranda Notifications kısmına geçelim.
Notifications kısmı, job görevini tamamladıktan sonra ilgili kişilere bilgi vermelerin ayarlandığı bölümdür. Ben bu örnek için işlem tamamlandığımda kendimi mail attırıyorum. Bu arada SQL Server 2008 de Mail Gönderme işlemi ile alakalı yazdığım yazıyı okumadıysanız okumanızı tavsiye ederim. Buradan erişebilirsiniz.
Notification larıda ayarladıktan sonra OK e basıyoruz. Job görevini almış durumda.:)
Bu arada ek bir bilgi vermek istiyorum. Bu jobların çalışabilmesi için SQL Server Agent in çalışır durumda olması gerekiyor. Bu bilgide aklınızda bulunsun.
Şimdi 3-4 dk kadar bekleyelim. Bu bekleme sırasında 3-4 defa BackUp işlemi gerçekleşecek ve mailler de mail kutumuza düşecektir.
Evet yeteri kadar bekledik. Mailimizi kontrol ettiğimizde BackUp Complete maillerinin gelmiş olduğunu görüyoruz.
Birde management studio üzerinde ki job un history sine bakalım. Bunun için Management Studio >> SQL Server Agent >> Jobs >> JobumuzunAdi kısmından sağ tık ile View History kısmını açalım.
Bu ekranda, oluşturduğumuz job un bütün tamamlanmış step history sine bakabilirsiniz.
Aklınıza takılan bir şey olursa yorum kısmından sorabilirsiniz.
İyi çalışmalar
Turgay Sahtiyan
...alıntıdır...
Gönderen Aslı zaman: 12:06 0 yorum
Etiketler: Örnekli-Resimli Anlatım, SQL
CASE SENSITIVE VERİTABANINDA ARAMA
31 Aralık 2009SELECT ad, soyadFROM b_KisiBilgileriWHERE (UPPER(soyad) LIKE N'KENAR')
SELECT ad, soyadFROM b_KisiBilgileriWHERE (lower(soyad) LIKE N'kenar')
Database diagram support objects cannot be installed...
07 Aralık 2009Basit Trigger Örnekleri
31 Temmuz 2009-- Kullanıcının tablo üzerinde güncelleme yaptığında
-- değişiklik tarihi kolonunun otomatik olarak
-- güncelleme yapıldığı tarihi alınmasının sağlanması
-- için yazılan update trigger örneği
CREATE TRIGGER trigger_Guncellendi
ON Kisiler
for UPDATE
as
declare @id int
select @id = ziyaretID from deleted -- güncelleme için kayıt önce deleted (silinenler)
-- tablosuna gönderilir ardından da kayıt insert edilir
UPDATE Kisiler
SET degisiklikTarihi = getdate() --güncelleme yapıldığı tarihi db ye eklemiş olduk
WHERE ziyaretID=@id
--Kullanıcının birden fazla kayıt silmesini engellemek için yazılan bir delete trigger örneği
CREATE TRIGGER trigger_Silindi --Trigger adı
ON Kisiler --İlgili Tablo
for DELETE --Oluşturulacak trigger türü
as
declare @sayi int
select @sayi = count(*) from deleted --Silme işlemi için deleted (Silinmişler)
--tablosuna gönderilen kayıt sayısı
if @sayi>1
begin
rollback transaction
end
Gönderen Aslı zaman: 13:11 4 yorum
Etiketler: Örnekli-Resimli Anlatım, SQL
Web Uygulamalarında Dataset Kullanmak
24 Haziran 2009TC Kimlik No Kontrolü
18 Mayıs 2009
Algoritma:
TC Kimlik numaramız 11 basamaklı ve her bir rakamı kn ile ifade edelim(n€N)
TC no: k1k2k3k4k5k6k7k8k9k10k11 olsun.
tekler = k1+k3+k5+k7+k9
çiftler = k2+k4+k6+k8 (dikkat k10 yok!)
TC kimlik numarasının son iki basamağı (k10 ve k11) kontrol amaçlıdır. Şimdi o kontrolü
yapmak için aşağıdaki işlemler yapılır:
t1 = (tekler*3)+çiftler
c1 = (10 - (t1 mod10))mod10
t2 = c1 + çiftler
t3 = (t2*3)+tekler
c2 = (10 - (t3 mod10))mod10
Eğer,
c1 = k10 (yani Tc nonun 10.basamağı) ve c2=k11 (yani son basamak)
ozaman bu TC kimlik numarası geçerlidir denir.
Not bu C# kodunu web uygulaması vs yaparken de kullanabilrsiniz(messageBoxları çıkarmanız gerekebilir).
Numan GÖÇERİ
DataList içindeki DropDownList’in Value’sunu SelectedIndexChange'de alma
28 Nisan 2009
Senaryoda bir DataList'imiz olsun. O DataList'in içinde de DropDownList'imiz olsun. DropDownList'in SelectedValue'sunu yakalamak için aşağıdaki kodu yamamız yeterli olur.DropDownList ddl = sender as DropDownList;
string deger = ddl.Items[ddl.SelectedIndex].Value;
Gönderen Aslı zaman: 10:31 1 yorum
Etiketler: ASP.NET-AJAX
DropDownList ve Validation Conrol
27 Nisan 2009DropDownList'imizde bir alanın muhakkak seçilmesini ve seçilmediği taktirde uyarı vermesini istemiyorsak, DropDownList'in "Initial Value" özelliğinden faydalanabiliriz.
Zaman zaman bilgilendirmek ve dikkati çekmek için DropDownList'lere "Seçiniz.." vs gibi ibareler ekleriz. Seçili bir alan olmadığı taktirde uyarı göstermesini istiyorsak, bir RequiredFieldValidator ekleyelim, "Control to validate" özelliğine de muhakkak şeçili geçerli bir alanın olmasını istideğiniz DropDownList'i bağlayalım. Initial Value suna "Seçiniz.." itemının value sunu yazalım.
Gönderen Aslı zaman: 13:34 2 yorum
Etiketler: ASP.NET-AJAX
CETURK Java Teknoloji Günleri - Kıbrıs
13 Nisan 2009Bugüne kadar çok farklı konu ve teknoloji ile ilgili yaptığı ücretsiz etkinliklerle sektörünün gelişmesine katkıda bulunan CETURK etkinliklerine devam ediyor. İstanbul'da IBM, Microsoft, Yıldız Teknik Üniversitesi, Bahçeşehir Üniversitesi ve özel bir çok kurumda ücretsiz etkinlikler düzenleyen CETURK, 2009 yılında "CETURK Anadolu Bilişim Turu" başlıklı organizasyonda ülkemizin 7 bölgesinde en az 1 kere bilişim etkinliği hedeflemektedir. CETURK Anadolu Bilişim Turu 3 Ocak 2009'da Ankara'da Çankaya Üniversitesi'nde yapılan Java Teknolojileri Etkinliği ile başladı. Elazığ'ta Fırat Üniversitesi Atatürk Kültür Merkazi'nde yapılan "CETURK Yazılım Mimarisi Tasarımı Günü" etkinliği ile devam etti. Etkinliğe katılım her zamanki gibi ücretsiz olacak. Ayrıca her zaman olduğu gibi etkinliğe katılan kişilere çekiliş ile kitap hediye edilecek ve katılım sertifikası verilecek. Etkinliğe katılamayanlar için video kaydı yapılarak CETURK.TV'de yayınlanacak. Etkinliğe katılan 3 kişiye, ayrıca bu etkinlik haberini kişisel blogunda/sitesinde duyurup daha fazla kişinin faydalanması için bize destek olan 4 kişiye çekilişle Özcan Acar'ın aşağıdaki kitabından hediye edilecektir.CETURK Java Teknoloji Günleri - Kıbrıs 11.04.2009
CETURK Anadolu Bilişim Turu'nun 3. Durağı Kıbrıs... Doğu Akdeniz Üniversitesi Yazılım Kulübü işbirliği ile 11 ve 12 Nisan'da "CETURK Java Teknoloji Günü – Kıbrıs" etkinliği gerçekleşiyor. Etkinliğe 1 Almanya'dan, 2 İstanbul'dan ve 2 Ankara olmak üzere toplam 5 konuşmacı katılıyor.ETKİNLİK DETAYLARI Etkinlik Konusu : CETURK Java Teknoloji Günleri - Kıbrıs Etkinlik Türü : Workshop Kontenjan : 200 Etkinlik Tarihi - Saati : 11.04.2009 -- 11.04.2009 ( 13 - 16.30) ve 12.04.2009 ( 10:30- 16:00) Süre : 2 Gün Etkinlik Yeri : Doğu Akdeniz Üniversitesi - Mavi Salon - Kıbrıs ETKINLIK IÇERİĞİ 11 Nisan : Cumartesi ( 13.00-16.30)
12 Nisan Pazar ( 10.30- 16.00)ETKİNLİK HEDİYEMİZ
Özcan Acar'a kitap desteği için teşekkür ederiz.
Gönderen Aslı zaman: 07:02 0 yorum
Etiketler: Seminer Duyuruları


