InputAttributes in RowCreated (gridview)

P

Pipo

Hi,

I want to bind my checkboxes during Rowcreated in the gridview.
I want to render:
<asp:CheckBox ID="chkDIS1" runat="server" Checked='<%# Bind("DIS1") %>' />
I tried:
chk.InputAttributes.Add("Checked", "'<%# Bind(""" + "DIS" +
dtt.Rows(intRowCounter).Item(0).ToString + """)" + "%>'")
But then I get Checked="'<%# Bind("DIS1") %>'" notice the extra " before and
after '<%# Bind("DIS1") %>'
also
chk.InputAttributes.Add("Checked='<%# Bind(""" + "SID" +
dtt.Rows(intRowCounter).Item(0).ToString + """)" + "%>'", Nothing)
But this does nothing.
Does anybody knows how to do this?

tia
 
T

Teemu Keiski

Hi,

adding these in code via Attributes collection doesn't do anything. <%# ...
%> syntax is meaningful only to the page parser when Page is parsed from
declarative syntax (that is aspx, ascx etc). If you want to set these in
code, you'd do that in RowDataBound event, and access straight GridViewRow's
DataItem property which represents the single data item for that particular
row.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top