Checking Number in a String and calculate..

Please support our ASP.NET advertiser: $4.95 a Month - ASP.NET Web Hosting – Click Here!
Thread Solved
Reply

Join Date: Jan 2008
Posts: 25
Reputation: bharathi_n_r is an unknown quantity at this point 
Solved Threads: 0
bharathi_n_r bharathi_n_r is offline Offline
Light Poster

Checking Number in a String and calculate..

 
0
  #1
Nov 19th, 2008
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..

  1. Select Case DGridItem.Cells(8).Text
  2. Case "E4"
  3. txtLTa.ReadOnly = False
  4. CbLTA.Checked = True
  5. Case "E3"
  6. txtLTa.ReadOnly = False
  7. CbLTA.Checked = True
  8. Case "E2"
  9. txtLTa.ReadOnly = False
  10. CbLTA.Checked = True
  11. Case "E1"
  12. txtLTa.ReadOnly = False
  13. CbLTA.Checked = True
  14. Case Else
  15. CbLTA.Visible = False
  16. txtLTa.Visible = False
  17. 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.
  1. Dim PRCbLTA As String
  2. Dim CbLTA As CheckBox
  3. Dim txtLTa As TextBox
  4. Dim PRLta As Decimal
  5. txtLTa = CType(DGridItem.FindControl("txtLTA"), TextBox)
  6. CbLTA = CType(DGridItem.FindControl("CbLTA"), CheckBox)
  7. Dim Grade As String
  8. Grade = DGridItem.Cells(8).Text
  9. Dim i As Integer
  10. If Grade = "E" & i <= 4 Then
  11. Response.Write(i)
  12. End IF
It is returning me all 0's..Could anyone help me on this.
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 25
Reputation: bharathi_n_r is an unknown quantity at this point 
Solved Threads: 0
bharathi_n_r bharathi_n_r is offline Offline
Light Poster

Re: Checking Number in a String and calculate..

 
0
  #2
Nov 19th, 2008
Thanks for viewing.

I myself solved it..Thanks anyway...

Here is the Code.I used Replace

  1. Dim PRCbLTA As String
  2. Dim CbLTA As CheckBox
  3. Dim txtLTa As TextBox
  4. Dim PRLta As Decimal
  5. txtLTa = CType(DGridItem.FindControl("txtLTA"), TextBox)
  6. CbLTA = CType(DGridItem.FindControl("CbLTA"), CheckBox)
  7. Dim Grade As String
  8. Grade = Replace(DGridItem.Cells(8).Text, "E", "")
  9. If Grade <= 4 Then
  10. txtLTa.ReadOnly = False
  11. CbLTA.Checked = True
  12. Else
  13. CbLTA.Visible = False
  14. txtLTa.Visible = False
  15. End If
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC