17 Kasım 2014 Pazartesi

TemplateField içinde Row Index Öğrenme

<asp:TemplateField HeaderText="IsPolicyHolder">
<ItemTemplate>
<asp:CheckBox ID="chkBox1" runat="server" AutoPostBack="true" Checked="false" OnCheckedChanged="chkBox1_CheckedChanged"/>
</ItemTemplate>
</asp:TemplateField>
şeklinde bir check box tıklandığında hangi row olduğunu öğrenebilmek için
protected void chkBox1_CheckedChanged(object sender, EventArgs e) 
{
CheckBox chkbox = (CheckBox)sender;
GridViewRow Grow = (GridViewRow)chkbox.NamingContainer; // HANGİ ROW İÇİNDE
if (chkbox.Checked)
{
.........
}
}

27 Ağustos 2014 Çarşamba

Attempt by security transparent method to access security critical method failed.

Attempt by security transparent method 'package_block_control.SetInfo(Int32, System.String, System.String, System.String, System.String, Int32, System.String)' to access security critical method 'dsPackagesTableAdapters.tblPackagesTableAdapter..ctor()' failed.

Assembly 'App_Web_hvja3wp0, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' is marked with the AllowPartiallyTrustedCallersAttribute, and uses the level 2 security transparency model.  Level 2 transparency causes all methods in AllowPartiallyTrustedCallers assemblies to become security transparent by default, which may be the cause of this exception.


.NET 4.0 ve üstü site yayınlarında karşılaşılan bir durum:

Çözüm:


belirtilen FONKSİYON sütüne 

[SecuritySafeCritical]

Ekleyin, Örn:

 [SecuritySafeCritical]
    public void SetInfo(Int32 _SpecialOfferID, String _Resim, String _Detail, String _Country, String _ClassName, Int32 _OtelID , String _Style)
    
{
...
}

using System.Security;

Tanımınıda sayfaya ekleyin

Tamamdır.