Hello,
I have a datagrid based on a set of files in a directory, and I want the possibility to delete one or more of them by checking a checbox I added in the datagrid.
I can check the box, but, in no way whatsoever, I get a "True" status in by code behind.
I'm coding for DNN 04.08.02 in Microsoft Visual Studio 2005 (Professional edition)
A snippet below:
HTML-part:
<
asp:datagrid id="MP3FileList" runat="server" Width="100%" Font-Name="Verdana" AutoGenerateColumns="False"
AlternatingItemStyle-BackColor="#eeeeee" HeaderStyle-BackColor="Navy" HeaderStyle-ForeColor="White"
HeaderStyle-Font-Size="15pt" HeaderStyle-Font-Bold="True">
<columns>
<asp:TemplateColumn HeaderText="MP3 File" Visible="True">
<ItemTemplate>
<asp:Label ID="lblName"
Text='<%# DataBinder.Eval(Container.DataItem,"Name") %>'
Runat="server" />
</ItemTemplate>
</asp:TemplateColumn>
<asp:BoundColumn DataField="LastWriteTime" HeaderText="Last Write Time" ItemStyle-HorizontalAlign="Center" DataFormatString="{0:d}" />
<asp:BoundColumn DataField="Length" HeaderText="File Size" ItemStyle-HorizontalAlign="Right" DataFormatString="{0:#,### bytes}" />
<asp:TemplateColumn HeaderText="Delete" ItemStyle-HorizontalAlign="Center">
<ItemTemplate>
<asp:CheckBox id="chkSelect" Enabled="True" Runat="server"></asp:CheckBox>
</ItemTemplate>
</asp:TemplateColumn>
</
</columns>asp:datagrid>
Code behind part:
cb =
For Each dgi In MP3FileList.ItemsCType(dgi.Cells(0).FindControl("chkSelect"), CheckBox)If cb.Checked Then
strCheckedInt =
"True"
Else
strCheckedInt =
"False"
End If
'================ Start TraceLog ================
strItem =
"cmdDelete dgiCell(3)Cont(Find)"
strDetail =
strResult =
TraceLog(strModule, strItem, strDetail, strResult)
"Record#: " & MP3FileList.Items.ToString"to delete: " & strCheckedInt'================= End TraceLog =================
'OK tot hier...
strFieldName =
cb.Checked =
CType(dgi.FindControl("lblName"), Label).TextCType(dgi.FindControl("chkSelect"), CheckBox).CheckedIf cb.Checked Then
strCheckedInt =
"True"
Else
strCheckedInt =
"False"
End If
'================ Start TraceLog ================
strItem =
"cmdDelete Index"
strDetail =
strResult =
TraceLog(strModule, strItem, strDetail, strResult)
"Field: " & strFieldName"to delete: " & strCheckedInt'================= End TraceLog =================
Next
(Below is the tracelog part that I use for bdebugging purposes......)
Public Sub TraceLog(ByVal strModule As String, ByVal strItem As String, ByVal strDetail As String, ByVal strResult As String)If boolDoTraceLog Then
intLogRecord = intLogRecord + 1
Dim strDateTime As DateTime = Now()If Not IO.File.Exists(strTraceLog) Then
writer.WriteLine(
writer.Close()
Dim writer As IO.StreamWriter = IO.File.CreateText(strTraceLog)"Log#: " & intLogRecord & " Created: " & strDateTime & "; Module: " & strModule & "; Item: " & strItem & "; Detail: " & strDetail & "; Result: " & strResult)Else
writer.WriteLine(
writer.Close()
Dim writer As IO.StreamWriter = IO.File.AppendText(strTraceLog)"Log#: " & intLogRecord & " Append: " & strDateTime & "; Module: " & strModule & "; Item: " & strItem & "; Detail: " & strDetail & "; Result: " & strResult)End If
End If
End Sub