开发者

showing text along with checkbox in checkbox column in datagridview

开发者 https://www.devze.com 2023-04-03 12:42 出处:网络
I want to show the text along with checkbox in every cell in checkbox column in a datagridview.Is it possible?If it is,Please help me with the sample code.

I want to show the text along with checkbox in every cell in checkbox column in a datagridview.Is it possible?If it is,Please help me with the sample code.

Thanx in adva开发者_高级运维nce

I want in c# please.


Try something as below for the text of checkbox

<asp:TemplateField>
                    <ItemTemplate>
                        <asp:CheckBox ID="chkStatus" runat="server"
                            AutoPostBack="true" OnCheckedChanged="chkStatus_OnCheckedChanged"
                            Checked='<%# Convert.ToBoolean(Eval("Approved")) %>'
                            Text='<%# Eval("Approved").ToString().Equals("True") ? " Approved " : " Not Approved " %>' />
                    </ItemTemplate>                   
                </asp:TemplateField>

Code behind

((CheckBox)e.Row.FindControl("chkStatus")).Text="abc";
0

精彩评论

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