Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeUsing DNN Platf...Using DNN Platf...Administration ...Administration ...HELP!!! Checkbox in datagrid always return "False"HELP!!! Checkbox in datagrid always return "False"
Previous
 
Next
New Post
4/4/2008 8:41 AM
 

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


jos Richters www.visualdata.nl
 
Previous
 
Next
HomeHomeUsing DNN Platf...Using DNN Platf...Administration ...Administration ...HELP!!! Checkbox in datagrid always return "False"HELP!!! Checkbox in datagrid always return "False"


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out