开发者

Replacing Link Button and label with check boxes

开发者 https://www.devze.com 2023-01-27 13:56 出处:网络
This is my repeater in GUI and code behind ..I need to replace the \'Make Default\' linkbutton with a Check Box now. What I want to do is that When user Checks the checbox, the Default value is set to

This is my repeater in GUI and code behind ..I need to replace the 'Make Default' linkbutton with a Check Box now. What I want to do is that When user Checks the checbox, the Default value is set to TRUE in DB , Also when a check box is Checked, it will be grayed out..

NOW :( I was just trying to implement this but there's no CommandName attribute for checkbox and not even CommandArgument attribute!!

How do I change my code now ? :(

All I wanna do is replace that Link Button with Checkbox. Somebody please help me out with this..How do i pass arguments to this check box ..I need the command arguments for my "SetDefault" method that sets the address to TRUE if Default is selected

[EDIT]

I am not getting it..in my Link Button now I am passing 2 command argu开发者_开发技巧ments like this CommandArgument='<%# Eval("UserID") + "," + Eval("IsB") %>' Now how do i pass these two Comand arguments that I need for my SetDEfault method in checkebox!? ok i got it that we use OnCheckChanged event when its check box and ItemCommand event is used when its link button...I am just not getting how will I pass these two command arguments in my checkbox

[EDIT] Do I need to pass these two command arguments via text attribute ?

<asp:CheckBox Text='<%# Eval("UserID") + "," + Eval("IsB") %>' runat="Server"/>


You can just set check box AutoPostBack property to true and use OnCheckedChanged event to use update db.

For example.

<asp:CheckBox ID="CheckBox1" Checked='<%#Eval("Flag")%>' Text='<%#Eval("ItemID")%>'
                            CssClass="HiddenText" AutoPostBack="true" runat="server" OnCheckedChanged="CheckBox1_CheckedChanged" />


Since CheckBox doesnt have CommandName and CommandArgument properties, you could create your own Extended checkbox by extending it from CheckBox class. If you don't know how to do this then here you can find one Command Capable Checkbox


followed example here on this page..it worked http://www.cleancode.co.nz/blog/279/checkbox-repeater-event-handling-argument

0

精彩评论

暂无评论...
验证码 换一张
取 消