DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   ASP.NET (http://www.daniweb.com/forums/forum18.html)
-   -   Checking Number in a String and calculate.. (http://www.daniweb.com/forums/thread158269.html)

bharathi_n_r Nov 19th, 2008 6:30 am
Checking Number in a String and calculate..
 
Hi fellows,
My problem is, i have a datagrid where there is a boundcolumn which consists of Cadre(E1,E2.....E7).

In the same datagrid i also have two template column which consists of a textbox and a checkbox.I need to enable the textbox and check the checkbox by considering the cadre.The logic is that i got 60 employees in teh grid with various Cadre.I want to enable the textbox and Check box to the employee whose cadre is above E4(E4,E3,E2,E1).

I did this by using select case..

                Select Case DGridItem.Cells(8).Text
                Case "E4"
                    txtLTa.ReadOnly = False
                    CbLTA.Checked = True
                Case "E3"
                    txtLTa.ReadOnly = False
                    CbLTA.Checked = True
                Case "E2"
                    txtLTa.ReadOnly = False
                    CbLTA.Checked = True
                Case "E1"
                    txtLTa.ReadOnly = False
                    CbLTA.Checked = True
                Case Else
                    CbLTA.Visible = False
                    txtLTa.Visible = False
            End Select

But i would like to try it by keeping constant "E" and calculate the number using a IF Condition.This is what i did.
                Dim PRCbLTA As String
            Dim CbLTA As CheckBox
            Dim txtLTa As TextBox
            Dim PRLta As Decimal
            txtLTa = CType(DGridItem.FindControl("txtLTA"), TextBox)
            CbLTA = CType(DGridItem.FindControl("CbLTA"), CheckBox)
            Dim Grade As String
            Grade = DGridItem.Cells(8).Text
            Dim i As Integer
            If Grade = "E" & i <= 4 Then
            Response.Write(i)
            End IF
It is returning me all 0's..Could anyone help me on this.

bharathi_n_r Nov 19th, 2008 9:13 am
Re: Checking Number in a String and calculate..
 
Thanks for viewing.

I myself solved it..Thanks anyway...

Here is the Code.I used Replace

Dim PRCbLTA As String
            Dim CbLTA As CheckBox
            Dim txtLTa As TextBox
            Dim PRLta As Decimal
            txtLTa = CType(DGridItem.FindControl("txtLTA"), TextBox)
            CbLTA = CType(DGridItem.FindControl("CbLTA"), CheckBox)
            Dim Grade As String
            Grade = Replace(DGridItem.Cells(8).Text, "E", "")
            If Grade <= 4 Then
                txtLTa.ReadOnly = False
                CbLTA.Checked = True
            Else
                CbLTA.Visible = False
                txtLTa.Visible = False
            End If


All times are GMT -4. The time now is 9:04 pm.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC