By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,590 Members | 663 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,590 IT Pros & Developers. It's quick & easy.

CheckBox template always evaluate to False even if checked in a DataGrid hosted inside a TabStrip

P: n/a
CheckBox template always evaluate to False even if checked in a DataGrid
hosted inside a TabStrip in ASP.NET
Hi,

I am trying to develop an ASP.NET application. I am using TabStrip
(which is part of IE WebControls).

Inside a tab I have a datagrid defined as follows:

<iewc:multipage id="MultiPage_Control" style="Z-INDEX: 103; LEFT: 452px;
POSITION: absolute; TOP: 297px" tabIndex="3" runat="server"
Height="160px" Width="458px" BorderColor="#C0C0FF" BorderStyle="Ridge"
SelectedIndex="3">
<IEWC:PAGEVIEW>Customers
<DIV id="Layer6" style="WIDTH: 250px; POSITION: relative; HEIGHT: 80px">
<asp:datagrid id="dgAssignedTo" style="Z-INDEX: 104; LEFT: 13px;
POSITION: absolute; TOP: 17px" runat="server" BorderColor="black"
BorderWidth="1" CellPadding="3" AutoGenerateColumns="False">
<HeaderStyle BackColor="#00AAAA"></HeaderStyle>
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<asp:CheckBox id=CheckBox1 runat="server" Checked='<%#
DataBinder.Eval(Container.DataItem, "Active") %>'>
</asp:CheckBox>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Store Address">
<ItemTemplate>
<asp:Label ID="lblUsername" Text='<%#
DataBinder.Eval(Container.DataItem, "Username") %>' Runat="server" />
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Store Address">
<ItemTemplate>
<asp:Label ID="lblName" Text='<%#
DataBinder.Eval(Container.DataItem, "Name") %>' Runat="server" />
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:datagrid>
</DIV></IEWC:PAGEVIEW>
<IEWC:PAGEVIEW></IEWC:PAGEVIEW>
<IEWC:PAGEVIEW></IEWC:PAGEVIEW>
<IEWC:PAGEVIEW></IEWC:PAGEVIEW>
<IEWC:PAGEVIEW></IEWC:PAGEVIEW>
</iewc:multipage></form>

which is basically a datagrid which has a checkbox (1st column) and 2
other columns
(employee usernames).
What i want is when the user checks a checkbox, I can save that to the
database.

Public Sub cmdSave_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdSave.Click

Dim myDataGridItem As DataGridItem
Dim chkSelected As System.Web.UI.WebControls.CheckBox
Dim strUserName As String
conHelpdesk.Open()
For Each myDataGridItem In dgAssignedTo.Items

chkSelected = myDataGridItem.FindControl("CheckBox1")
' If chkSelected.Checked Then
strUserName =
CType(myDataGridItem.FindControl("lblUsername"), Label).Text
System.Diagnostics.Debug.WriteLine(strUserName)
strCriteria = "Update employee Set Active=@strActive " _
& " Where Username=@strUsername"

System.Diagnostics.Debug.WriteLine(strCriteria)
cmdSelect4 = New SqlCommand(strCriteria, conHelpdesk)
cmdSelect4.Parameters.Add("@strUsername", strUserName)
cmdSelect4.Parameters.Add("@strActive", SqlDbType.Bit).Value
= chkSelected.Checked
cmdSelect4.ExecuteNonQuery()

' End If
Next

conHelpdesk.Close()

End Sub

However even if the user checks the checkbox next to the employee column
'chkSelected'
always evaluates to false.

This same code when the datagrid is outside of the TabStrip executes
fine but inside the
TabStrip always evaluates to false.

I have checked MSDN KB but cannt find any errors.

Pls Help,
Rgs,
Mehul

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.