<?xml version="1.0" encoding="iso-8859-9" ?>
<?xml-stylesheet type="text/xsl" href="RSS_xslt_style.asp" version="1.0" ?>
<rss version="2.0" xmlns:WebWizForums="http://syndication.webwizguide.com/rss_namespace/">
 <channel>
  <title>Datakent Forum : C# GridView da nesnelere olay atama VE LINQ</title>
  <link>http://forum.datakent.com/</link>
  <description>XML içerik linki; Datakent Forum : C# &amp; ASP.NET : C# GridView da nesnelere olay atama VE LINQ</description>
  <pubDate>Thu, 30 Apr 2026 21:05:38 +0000</pubDate>
  <lastBuildDate>Sun, 19 Apr 2015 09:59:48 +0000</lastBuildDate>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Web Wiz Forums 9.54</generator>
  <ttl>360</ttl>
  <WebWizForums:feedURL>forum.datakent.com/RSS_post_feed.asp?TID=2778</WebWizForums:feedURL>
  <image>
   <title>Datakent Forum</title>
   <url>http://forum.datakent.com/forum_images/datakent.com_forums.png</url>
   <link>http://forum.datakent.com/</link>
  </image>
  <item>
   <title>C# GridView da nesnelere olay atama VE LINQ : C# GridView sat&#305;rlar&#305;ndaki nesnelere...</title>
   <link>http://forum.datakent.com/forum_posts.asp?TID=2778&amp;PID=5619#5619</link>
   <description>
    <![CDATA[<strong>Yazar:</strong> <a href="http://forum.datakent.com/member_profile.asp?PF=1" rel="nofollow">murat turan</a><br /><strong>Konu:</strong> 2778<br /><strong>Gönderim Zamanı:</strong> 19.Nisan.2015 Saat 09:59<br /><br />C# GridView satırlarındaki nesnelere olay atama VE LINQ<div><br></div><div><br></div><div><div><br></div><div><br></div><div>//--------------------------</div><div>//ASPX &nbsp;KISMI</div><div>//--------------------------</div><div><br></div><div>&lt;%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %&gt;</div><div><br></div><div>&lt;!DOCTYPE html&gt;</div><div><br></div><div>&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;</div><div>&lt;head runat="server"&gt;</div><div>&nbsp; &nbsp; &lt;title&gt;&lt;/title&gt;</div><div><br></div><div>&nbsp; &nbsp; &lt;script type="text/javascript"&gt;</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; function test1(deger) {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; alert(deger);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; }</div><div><br></div><div>&nbsp; &nbsp; &lt;/script&gt;</div><div><br></div><div>&lt;/head&gt;</div><div>&lt;body&gt;</div><div>&nbsp; &nbsp;&nbsp;</div><div>&nbsp; &nbsp; &lt;form id="form1" runat="server"&gt;</div><div>&nbsp; &nbsp; &lt;div&gt;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &lt;asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" OnRowDataBound="GridView1_RowDataBound"&gt;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;Columns&gt;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;!-- 1. yontem. CS ye kod yazman gerek. bkz:GridView1_RowDataBound --&gt;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;asp:TemplateField ShowHeader="False"&gt;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;ItemTemplate&gt;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;asp:ImageButton ImageUrl="~/btn3.png" ID="btnGuncelle" runat="server" CausesValidation="false" CommandName=""&gt;&lt;/asp:ImageButton&gt;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/ItemTemplate&gt;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/asp:TemplateField&gt;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;!-- 2. yontem. CS ye kod yazmadan --&gt;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;asp:TemplateField ShowHeader="False"&gt;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;ItemTemplate&gt;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;asp:ImageButton ImageUrl="~/btn3.png" ID="btnGuncelle_2" runat="server" CausesValidation="false" CommandName="" OnClientClick='&lt;%# "test1(\u0027" + DataBinder.Eval(Container.DataItem,"rid") + "\u0027);" %&gt;' &gt;&lt;/asp:ImageButton&gt;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/ItemTemplate&gt;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/asp:TemplateField&gt;</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;!-- 3. yontem. CS ye kod yazmadan --&gt;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;asp:TemplateField ShowHeader="False"&gt;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;ItemTemplate&gt;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;img src="~/btn3.png" id="btnGuncelle_3" runat="server" onclick='&lt;%# "test1(\u0027" + DataBinder.Eval(Container.DataItem,"rid") + "\u0027);" %&gt;' /&gt;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/ItemTemplate&gt;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/asp:TemplateField&gt;</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;asp:BoundField DataField="rid" /&gt;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;asp:BoundField DataField="etVal" /&gt;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/Columns&gt;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &lt;/asp:GridView&gt;</div><div>&nbsp; &nbsp; &lt;/div&gt;</div><div>&nbsp; &nbsp; &lt;/form&gt;</div><div>&lt;/body&gt;</div><div>&lt;/html&gt;</div><div><br></div><div><br></div><div><br></div><div>//--------------------------</div><div>// CS &nbsp; KISMI</div><div>//--------------------------</div><div><br></div><div>using System;</div><div>using System.Linq;</div><div>using System.Web.UI;</div><div>using System.Web.UI.WebControls;</div><div><br></div><div>public partial class _Default : System.Web.UI.Page</div><div>{</div><div>&nbsp; &nbsp; protected void Page_Load(object sender, EventArgs e)</div><div>&nbsp; &nbsp; {</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; if (!IsPostBack)</div><div>&nbsp; &nbsp; &nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //LINQ ILE VERI BAGLANTISI</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DataClassesDataContext dbx = new DataClassesDataContext();</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var list1 = from x1 in dbx.EvrakTurus</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; select x1;</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //GRID'E YUKLE</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; GridView1.DataSource = list1;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; GridView1.DataBind();</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; }</div><div><br></div><div>&nbsp; &nbsp; }</div><div><br></div><div>&nbsp; &nbsp; protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)</div><div>&nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; //GRID'IN SATIRLARI OLUSURKEN TETIKLENEN OLAY</div><div>&nbsp; &nbsp; &nbsp; &nbsp; if (e.Row.RowType == DataControlRowType.DataRow)</div><div>&nbsp; &nbsp; &nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int _id = Convert.ToInt32(DataBinder.Eval(e.Row.DataItem, "rid"));</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ImageButton btn1 = e.Row.Cells&#091;0&#093;.FindControl("btnGuncelle") as ImageButton;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; btn1.OnClientClick = String.Format("test1({0});", _id.ToString());</div><div>&nbsp; &nbsp; &nbsp; &nbsp; } &nbsp;&nbsp;</div><div>&nbsp; &nbsp; }</div><div>}</div></div><div><br></div><div><br></div>]]>
   </description>
   <pubDate>Sun, 19 Apr 2015 09:59:48 +0000</pubDate>
   <guid isPermaLink="true">http://forum.datakent.com/forum_posts.asp?TID=2778&amp;PID=5619#5619</guid>
  </item> 
 </channel>
</rss>