CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 4 1234 LastLast
Results 1 to 15 of 58

Thread: RowDataBound(:

  1. #1
    Join Date
    Mar 2009
    Location
    Singapore
    Posts
    53

    Question RowDataBound(:

    hello(:
    i need another help for this prob..
    i hav to knw hw to use rowDataBound(:

    objective - gotta generate an email for the user who has created ticket on a problem wid all the details.

    i'm able to retrieve all the records of the tickets bt i want to display only the specific record of the user.

    how do i start abt doin tht??

    pls help any help much appreciated..
    thx(:

  2. #2
    Join Date
    Jun 2004
    Location
    Kashmir, India
    Posts
    6,808

    Re: RowDataBound(:

    You should be doing the filtering of the records on the database side. Write a proper query that will give you the desired record.

    What is it that you want to do with RowDataBound event?

  3. #3
    Join Date
    Mar 2009
    Location
    Singapore
    Posts
    53

    Re: RowDataBound(:

    hello Shuja Ali or any1 else who knows the answer to this qn,pls help

    i have these codes which does the calculations for auto assigning of the tickets to the support staff to attend to their ticket.

    but i'm not sure if i'm supposed to write these codes in the code-behind or in the classes where the sql statements are defined??

    any idea?

  4. #4
    Join Date
    Jun 2004
    Location
    Kashmir, India
    Posts
    6,808

    Re: RowDataBound(:

    Anything that has to do with the database should be written in the database side of the code or if you have Business Layer (classes that define business logic), then you should write it there.

  5. #5
    Join Date
    Mar 2009
    Location
    Singapore
    Posts
    53

    Re: RowDataBound(:

    i don't have a business layer class..i don't know what is that..
    i was told to put the codes in the classes page where i have the sql statements..
    so is that the right way??

  6. #6
    Join Date
    Jun 2004
    Location
    Kashmir, India
    Posts
    6,808

    Re: RowDataBound(:

    Yes that should be the right way of doing it.

  7. #7
    Join Date
    Mar 2009
    Location
    Singapore
    Posts
    53

    Re: RowDataBound(:

    okay..thanx so much..
    another one mre qn!(:

    the task which i'm doing is to actually assign the ticket submitted bny the user to a support staff automatically so they can attend to it..these support staffs have their own quotas..
    so i came out with this formula to implement this concept..

    the formula is -> QuotaAns = (1 / (TotalTickets + 1)) * Quota

    the quotaAns will determine who to give the ticket to..this formula muz calculate for all the support staff and see who has the highest quota will receive the ticket..

    for example: if support Staff A's Quota is 50% and B's quota is 30% and C's quota is 20%
    the formula will be implemented this way: QuotaAns = (1/(1+1))*50%

    so this will be used for all the support staff and who has the highest quotaAns gets the ticket.
    the 1 always remains the same because its the one new ticket..total ticket is for that particular staff which will be accumilated..

    i've got to implement this in my codes and i did this :

    Public Function CalculateQuota() As Double
    Dim newTicket As Integer = 1
    Dim TotalTickets As Integer
    Dim Quota As Double
    Dim QuotaArr As String
    Dim QuotaAns As Double

    QuotaAns = (1 / (TotalTickets + 1)) * Quota

    If QuotaAns < ((SupportStaffID = "10") And (SupportStaffID = "11") And (SupportStaffID = "15")) Then
    End If

    End Function

    but i'm stuck half way..i don't know how to move on..any help pls??

  8. #8
    Join Date
    Mar 2009
    Location
    Singapore
    Posts
    53

    Re: RowDataBound(:

    i edited and came out with another kind of codes.
    do u think its correct??
    can u help me pls??
    thx

    Public Function CalculateQuota() As Double
    Dim newTicket As Integer = 1
    Dim TotalTickets As Integer
    Dim Quota As Double
    Dim QuotaArr() As Double
    Dim QuotaAns As Double
    Dim SupportStaffID As Integer
    Dim i As Integer

    For i = (SupportStaffID = 10) To (SupportStaffID = 15)
    QuotaAns = (1 / (TotalTickets + 1)) * Quota
    QuotaArr(i) = QuotaAns
    Next i

    If QuotaArr(i) > (SupportStaffID = 11) Or (SupportStaffID = 15) Then
    newTicket = (SupportStaffID = 10)
    ElseIf QuotaArr(i) > (SupportStaffID = 10) Or (SupportStaffID = 15) Then
    newTicket = (SupportStaffID = 11)
    Else
    newTicket = (SupportStaffID = 15)
    End If

    End Function

  9. #9
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: RowDataBound(:

    Quota has no value assigned to it in the code posted.

    Your if statements look like they need to be part of your loop.

    Not sure about the for statement you are using, never seen one done like that before.

    I also see no need for the QuotaArr. If the if statements where within the loop you could simply use the QuotaAns.

    NewTicket is not used once assigned so I have no idea what it is for but once the statements are placed in the loop it will only conatin the value for the last run of the loop.

    Your function does not return a value.

    SupportStaffID is also not assigned but you are checking its value. Its value will always be 0 if you do not assign it.

    Seems like maybe this needs to be a parameter passed to the function rather than a local variable.
    Last edited by DataMiser; April 6th, 2009 at 09:01 AM.

  10. #10
    Join Date
    Mar 2009
    Location
    Singapore
    Posts
    53

    Re: RowDataBound(:

    ohh okok..
    i kind of get what you are saying..
    i'll try to go work on the codes again..
    and see if it works..thanx alot for your help..
    i'll get back soon!(:

  11. #11
    Join Date
    Mar 2009
    Location
    Singapore
    Posts
    53

    Re: RowDataBound(:

    hey i tried putting my if statements into the for loop and passed my supportStaffID parameter into the function and took out the QuotaArr which u found it redundant if its inside my loop..
    but nth works..i'll post my codes here..if u don't mind,pls help me check and work with me to solve this pls..thanx alot(:

  12. #12
    Join Date
    Mar 2009
    Location
    Singapore
    Posts
    53

    Re: RowDataBound(:

    ok this is my UI for submit ticket :
    i have the different fields such as the subject,description,due date,the category type etc..
    and a submit button

    as soon as the user fills in all the fields and clicks on submit,the system will save the records in the database and automatically assign the ticket to a support staff depending on the quota for each support staff..the quota is saved in the database and i've gotta retrieve the value from the database.

    datz y i came out wid the formula :
    QuotaAns = (1 / (TotalTickets + 1)) * Quota
    1 stands for that one new ticket juz submitted and the total tickets stands for the total tickets the particular staff has currently and the quota amount should be retrieved from the database..
    quotaAns is the value which i should compare with the other staffs to determine to who the new ticket should go to.

    and i put in the codes in the classes whr i have the sql statements..
    i have this sql statement to retrieve the number of total ticket each staff has:
    Code:
    Public Function DBSelect_TotalTickets(Optional ByVal SupportStaffID As Integer = 0) As DataTable
            Dim local_dbConn As New SqlConnection
            Dim local_sqlCommand As New SqlCommand
    
            local_dbConn = db_conn.DBConn
            local_sqlCommand.Connection = local_dbConn
    
            local_sqlCommand.CommandText = "SELECT COUNT(ID) FROM ITHelpDesk.dbo.Tickets where SupportStaffID = @xSupportStaffID"
            local_sqlCommand.CommandText = CommandType.Text
    
            Dim sql_adapter As New SqlDataAdapter(local_sqlCommand)
            Dim dt As New DataTable
            sql_adapter.Fill(dt)
            If dt.Rows.Count > 0 Then
                dt.PrimaryKey = New DataColumn() {dt.Columns("ID")}
            End If
    
            local_dbConn.Close()
            Return dt
    
        End Function
    and i have this sql statement to retrieve the ID of the newest ticket inserted:
    Code:
      Public Function DBSelect_NewTicketID() As DataTable
            Dim local_dbConn As New SqlConnection
            Dim local_sqlCommand As New SqlCommand
    
            local_dbConn = db_conn.DBConn
            local_sqlCommand.Connection = local_dbConn
    
            local_sqlCommand.CommandText = "SELECT MAX(ID) FROM ITHelpDesk.dbo.Tickets"
            local_sqlCommand.CommandText = CommandType.Text
    
            Dim sql_adapter As New SqlDataAdapter(local_sqlCommand)
            Dim dt As New DataTable
            sql_adapter.Fill(dt)
            If dt.Rows.Count > 0 Then
                dt.PrimaryKey = New DataColumn() {dt.Columns("ID")}
            End If
    
            local_dbConn.Close()
            Return dt
    
        End Function
    and this the function i have to do the calculation;
    Code:
      Public Function CalculateQuota(Optional ByVal SupportStaffID As Integer = 0) As Double
            Dim newTicket As Integer = 1
            Dim TotalTickets As Integer
            Dim Quota As Double
            ' Dim QuotaArr() As Double = Nothing
            Dim QuotaAns As Double
            Dim i As Integer
    
            For i = 10 To 15
                QuotaAns = (1 / (TotalTickets + 1)) * Quota
                'QuotaArr(i) = QuotaAns
    
                If QuotaAns > (SupportStaffID = 11) Or (SupportStaffID = 15) Then
                    newTicket = (SupportStaffID = 10)
    
                ElseIf QuotaAns > (SupportStaffID = 10) Or (SupportStaffID = 15) Then
                    newTicket = (SupportStaffID = 11)
                Else
                    newTicket = (SupportStaffID = 15)
                End If
            Next i
    
    
        End Function
    and this the code i have behind my button:
    Code:
     Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
            Dim clsSupportStaffQuota_Obj As New clsSupportStaffQuota
            clsSupportStaffQuota_Obj.CalculateQuota()
        End Sub
    i dunno what is going wrong here..please do help me..
    it'll seriously be appreciated..
    thx alot..do reply me asap..
    thanx thanx!(:
    Last edited by BabyAngel; April 6th, 2009 at 08:10 PM.

  13. #13
    Join Date
    Mar 2009
    Location
    Singapore
    Posts
    53

    Re: RowDataBound(:

    i debugged my codes under the calculateQuota function..
    but al the values are 0..
    how do i pass in the value..
    i seriously having so much of headache with this..
    pls help me..

  14. #14
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: RowDataBound(:

    I am not sure what you are trying to do with these lines of code

    Code:
    If QuotaAns > (SupportStaffID = 11) Or (SupportStaffID = 15) Then
                    newTicket = (SupportStaffID = 10)
    
                ElseIf QuotaAns > (SupportStaffID = 10) Or (SupportStaffID = 15) Then
                    newTicket = (SupportStaffID = 11)
                Else
                    newTicket = (SupportStaffID = 15)
                End If
    If I am not mistaken what you are in effect doing with this code is saying

    If (QuotaAns > True) Or (SupportStaffID = 15) then
    or
    If (QuotaAns > False) Or (SupportStaffID = 15) then ' Depending on the value of supportstaffid

    NewTicket=True ' or maybe NewTicket=False depending on the value passed in supportstaffid.

    I doubt that this is what you are wanting to do here

    As written it appears that the first part of the if will almost if not always be true Assuming QuotaAns > 0 or SupportStaffID=15

    What value are you actually trying to assign to new ticket?

    You also are not returning a value.

    For example if you wanted the value of NewTicket returned to the calling code you would add a line near the bottom [just above the end fucntion]

    Code:
    Return NewTicket
    Last edited by DataMiser; April 6th, 2009 at 09:03 PM.

  15. #15
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: RowDataBound(:

    This is totally wrong:
    Code:
    QuotaAns > (SupportStaffID = 11) Or (SupportStaffID = 15)
    is the same thing as:
    Code:
    QuotaAns > (TRUE) Or (TRUE)
    or

    Code:
    QuotaAns > (FALSE) Or (FALSE)

    not what you want

    Use Select Case for SupportStaffID
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

Page 1 of 4 1234 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured