我綁定複選框字段數據庫,並希望顯示實際值,如果在數據庫中它是1,那麼複選框應在gridview中打勾,否則未選中。我試過了,但是我的代碼沒有顯示覆選框中的實際值,總是沒有選中。綁定複選框與數據庫列
CODE:
<asp:GridView ID="GridViewSmsComplaints" AllowPaging="True" runat="server" AutoGenerateColumns="false" CssClass="mGrid" Width="450px" OnPageIndexChanging="GridViewSmsComplaints_PageIndexChanging" >
<Columns>
<asp:BoundField HeaderText="ID" DataField="ID" />
<asp:BoundField HeaderText="Recieving Date" DataField="RecievingDate" />
<%--<asp:BoundField HeaderText="ToMobileNo" DataField="ToMobileNo" /> --%>
<asp:BoundField HeaderText="FromMobileNo" DataField="FromMobileNo" />
<asp:BoundField HeaderText="Message" DataField="Message" />
<asp:TemplateField HeaderText="IsComplaint">
<ItemTemplate>
<asp:CheckBox ID="ckboxIsComplaint" OnCheckedChanged="ckboxIsComplaint_CheckedChanged" AutoPostBack="true" runat="server" Value='<%# Eval("IsComplaint") %>' />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
的.cs
SELECT [ID]
,REPLACE(convert(varchar, ReceivedMessages.ReceivedDateTime, 106), ' ','/') as RecievingDate
,[ToMobileNo]
,[FromMobileNo]
,[Message],
[IsComplaint]
FROM [CmsSMSDb].[dbo].[ReceivedMessages]
where Convert(date,ReceivedDateTime)>= @DateFrom AND Convert(date,ReceivedDateTime)<= @DateTo AND IsComplaint=1
你能在那裏你也請張貼代碼中的數據綁定,在後面的類代碼。謝謝 – Christos