tags:

views:

39

answers:

1

Hi;

asp.net code this code in gridview

<asp:CheckBox ID='<%# "CheckBox".Concat(Container.DataItemIndex) %>' runat="server" />

my code is not work. how to make ?

i want to

<asp:CheckBox ID="CheckBox1" runat="server" />
<asp:CheckBox ID="CheckBox2" runat="server" />
<asp:CheckBox ID="CheckBox3" runat="server" />
A: 

You can't set the ID programmatically like that on serverside controls - unless you're using ASP.NET 4, that is! :) See this article on "ASP.NET 4.0 ClientID Overview" or MSDN on ASP.NET Web Server Control Identification.

Another option is to simply remove the runat="server" attribute and get the value server-side using a simple Request.Form. Would that work for your scenario?

Jakob Gade
i dont used Asp.net 4.0 :S , i need inline ok ? , i dont want client id
Oraclee
Forcing a specific ID always ends up as a mess, it's not recommended. Why do you need to set control the ID-attribute? If you're using jQuery, maybe you can just use uniqe CSS classes to identify the checkboxes instead.
Jakob Gade
@Jakob Gade, my english is little. i need inline '<%# "CheckBox".Concat(Container.DataItemIndex) %>'
Oraclee