﻿
{"id":850,"date":"2012-08-16T17:48:35","date_gmt":"2012-08-16T17:48:35","guid":{"rendered":"http:\/\/www.gencayyildiz.com\/blog\/?p=850"},"modified":"2012-08-16T17:57:29","modified_gmt":"2012-08-16T17:57:29","slug":"repeater-veya-datalist-kontrollerinde-radiobutton-ile-tek-secim","status":"publish","type":"post","link":"https:\/\/www.gencayyildiz.com\/blog\/repeater-veya-datalist-kontrollerinde-radiobutton-ile-tek-secim\/","title":{"rendered":"Repeater veya DataList Kontrollerinde RadioButton \u0130le Tek Se\u00e7im"},"content":{"rendered":"<div id=\"fb-root\"><\/div>\n<p>Bazen Repeater veya DataList kontrollerinde RadioButton nesnesiyle tek se\u00e7im yapma ihtiyac\u0131nda olabiliriz.Mant\u0131ken RadioButton nesnesinin GrupName \u00f6zelli\u011fine isim verdikten sonra, Repeater veya DataList&#8217;te tekrarlatt\u0131ktan sonra tek se\u00e7im yapabilece\u011fini d\u00fc\u015f\u00fcn\u00fcr\u00fcz.Ma\u011flesef bu \u015fekilde istedi\u011fimiz sonuca varam\u0131yoruz.\u015eimdi size bu ihtiyac\u0131n nas\u0131l giderilece\u011fini pratik olarak g\u00f6sterece\u011fim.\u00d6rnek olarak DataList nesnesini kullanaca\u011f\u0131m. <\/p>\n<p>\u015eimdi varsayal\u0131m ki, bir DataList kontrol\u00fc \u00fczerinde \u00e7al\u0131\u015f\u0131yorum.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n        &lt;asp:DataList ID=&quot;dlOrnek&quot; RepeatColumns=&quot;5&quot; runat=&quot;server&quot; OnItemDataBound=&quot;dlOrnek_ItemDataBound&quot;&gt;\r\n            &lt;ItemTemplate&gt;\r\n                &lt;asp:RadioButton ID=&quot;rbOrnek&quot; Checked=&quot;false&quot; GroupName=&quot;rbOrnekGrup&quot; Text=&quot;Se\u00e7in&quot;\r\n                    onKeyPress=&quot;return suppress(event);&quot; runat=&quot;server&quot; \/&gt;\r\n            &lt;\/ItemTemplate&gt;\r\n        &lt;\/asp:DataList&gt;\r\n<\/pre>\n<p>G\u00f6rd\u00fc\u011f\u00fcn\u00fcz gibi DataList kontrol\u00fcm\u00fcz\u00fcn OnItemDataBound Event\u0131na &#8220;dlOrnek_ItemDataBound&#8221; ad\u0131nda bir metod ba\u011fl\u0131.RadioButton nesnemizin ise onKeyPress \u00f6zelli\u011finde ise &#8220;return suppress(event);&#8221; \u015feklinde bir JavaScript metodu tan\u0131mlanm\u0131\u015f.\u015eimdi bu metodlar\u0131 yazal\u0131m.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n    protected void dlOrnek_ItemDataBound(object sender, DataListItemEventArgs e)\r\n    {\r\n        if (e.Item.ItemType != ListItemType.Item &amp;&amp; e.Item.ItemType != ListItemType.AlternatingItem)\r\n            return;\r\n        RadioButton rd = e.Item.FindControl(&quot;rbOrnek&quot;) as RadioButton;\r\n        string script = &quot;SetSingleRadioButton('&quot; + rd.ClientID + &quot;',this)&quot;;\r\n        rd.Attributes.Add(&quot;onclick&quot;, script);\r\n    }\r\n<\/pre>\n<p>ve JavaScript kodumuz,<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n    &lt;script type=&quot;text\/javascript&quot;&gt;\r\n        function SetSingleRadioButton(nameregex, current) {\r\n            re = new RegExp(nameregex);\r\n            for (i = 0; i &lt; document.forms&#x5B;0].elements.length; i++) {\r\n                elm = document.forms&#x5B;0].elements&#x5B;i];\r\n                if (elm.type == 'radio') {\r\n                    if (elm != current) {\r\n                        elm.checked = false;\r\n                    }\r\n                }\r\n            }\r\n            current.checked = true;\r\n        }\r\n    &lt;\/script&gt;\r\n<\/pre>\n<p>\u0130\u015fte i\u015fimiz bitmi\u015ftir.Art\u0131k DataList i\u00e7inde sayd\u0131r\u0131lan RadioButton kontrol\u00fcnde tek se\u00e7im yapabiliriz.<br \/>\nFaydalanman\u0131z dile\u011fiyle,<br \/>\n\u0130yi \u00c7al\u0131\u015fmalar&#8230;<\/p>\n<!-- AddThis Advanced Settings generic via filter on the_content --><!-- AddThis Share Buttons generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"<p>Bazen Repeater veya DataList kontrollerinde RadioButton nesnesiyle tek se\u00e7im yapma ihtiyac\u0131nda olabiliriz.Mant\u0131ken RadioButton nesnesinin GrupName \u00f6zelli\u011fine isim verdikten sonra, Repeater veya DataList&#8217;te tekrarlatt\u0131ktan sonra tek se\u00e7im yapabilece\u011fini d\u00fc\u015f\u00fcn\u00fcr\u00fcz.Ma\u011flesef bu \u015fekilde istedi\u011fimiz sonuca varam\u0131yoruz.\u015eimdi size&#46;&#46;&#46;<!-- AddThis Advanced Settings generic via filter on get_the_excerpt --><!-- AddThis Share Buttons generic via filter on get_the_excerpt --><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10,18],"tags":[264,265,40,263],"class_list":["post-850","post","type-post","status-publish","format-standard","hentry","category-asp-net","category-javascript","tag-datalist","tag-javascript-2","tag-radiobutton","tag-repeater"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/posts\/850","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/comments?post=850"}],"version-history":[{"count":0,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/posts\/850\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/media?parent=850"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/categories?post=850"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gencayyildiz.com\/blog\/wp-json\/wp\/v2\/tags?post=850"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}