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

Discussion in 'ASP .Net' started by mehul, May 3, 2004.

  1. mehul

    mehul Guest

    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!
    mehul, May 3, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. yurps
    Replies:
    1
    Views:
    6,887
    rajeshthangarasu1983
    Feb 29, 2008
  2. Eric via .NET 247

    [ASP.net / C#] Checkbox Checked Always false

    Eric via .NET 247, Mar 25, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    9,366
    dunshRB
    Mar 25, 2005
  3. VB Programmer
    Replies:
    1
    Views:
    4,420
    Ken Cox [Microsoft MVP]
    Apr 13, 2005
  4. Alan Silver
    Replies:
    2
    Views:
    603
    Alan Silver
    Jul 20, 2006
  5. Rich_C
    Replies:
    0
    Views:
    92
    Rich_C
    Aug 17, 2006
Loading...

Share This Page