-
Re: RowDataBound(:
hello there..
i've got a new problem which i'm facing now..
i'm now working on a search function..i'm suppose to search the tickets based on the category..
i've got a dropdown list on my UI so user can select the category and click on the submit button to get the result..
i've done these codes below but it doesn't seem to work..can someone help me with this?thx
Code:
Sub SearchCat(Optional ByVal IsDataBaseSelect As String = "")
If IsDataBaseSelect <> "" Then
Dim clsTickets_Obj As New clsTickets
If lblCategory.Text <> "" Then
If ddl_Category.SelectedIndex <> -1 Then
lblCategory.Text = ddl_Category.SelectedItem.Text
End If
dt = clsTickets_Obj.DBSelect_ByTicketCategoryID(ddl_Category.SelectedValue)
'dt = clsTickets_Obj.DBSelect_ByTicketCategoryID(lblCategory.Text)
Else
dt = clsTickets_Obj.DBSelect_ByTicketCategoryID
End If
' Keep The Data on view state
ViewState("dt") = dt
GridView1.EditIndex = -1
Else
dt = DirectCast(ViewState("dt"), DataTable)
End If
GridView1.DataSource = dt
GridView1.DataBind()
End Sub
i have this code under my dropdown list:
Code:
Protected Sub ddl_Category_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddl_Category.PreRender
If Page.IsPostBack = False Then
Dim ClsTicketCategory_Obj As New clsTicketCategory
ddl_Category.DataSource = ClsTicketCategory_Obj.DBSelect()
ddl_Category.DataTextField = "Name0"
ddl_Category.DataValueField = "ID"
ddl_Category.DataBind()
' Set Default To Printers
If ddl_Category.Items.Count > 0 Then
If ddl_Category.Items.FindByText("NoteBooks").Text <> "" Then
ddl_Category.Items.FindByText("NoteBooks").Selected = True
' Putting the Title on the GUI
lblCategory.Text = ddl_Category.SelectedItem.Text
Else
ddl_Category.Items(0).Selected = True
' Putting the Title on the GUI
lblCategory.Text = ddl_Category.SelectedItem.Text
End If
End If
BindGridView("ChangeValue")
End If
End Sub
but when i run the page,i select the category,but i cant get the result which i expect..it actually retrieves all the data from the database..
please help someone!! :(
thanx!
-
Re: RowDataBound(:
I can't tell much from what you have posted I assume you are calling some functions that were not posted and that is where the actual selecting is done so there is nothing here to indicate what the problem may be.
On another note the part under the combo box looks rather odd.
It appears that If the text "NoteBooks" exists in the list then it will always be selected and if not then the first item will always be selected? Somehow I doubt that is the way you want it to work. If it is the way you want it then why even use a combo box?
-
Re: RowDataBound(:
actually i dont want the default value to be notebooks when the page is run..i want the value to be "select"..i dont know how to make it that way..any ideas?
-
Re: RowDataBound(:
hey ya..i managed to solve this issue!(:
i've got one more problem..i guess you remember my questions on the auto assign quota system..(:
i managed to solve that issue as in,i'm able to get the quota and the supportstaffid to whom the new ticket should be assigned to..
everything is working fine except that,after getting the new supportstaffid, i want to update my tickets database table to that id..
i've got this line of statement in behind my submit button:
Code:
clsTickets_Obj.DBUpdateSupportStaffID(clsTickets_Obj.DBSelect_NewTicketID)
having this line,when i debug and step over,it goes to the "DBUpdateSupportStaffID" funtion and there comes the error
which says :
"UPDATE statement conflicted with COLUMN FOREIGN KEY constraint 'FK_Tickets_SupportStaff'. The conflict occurred in database 'ITHelpdesk', table 'SupportStaff', column 'ID'.
The statement has been terminated. "
Code:
Line 384: local_sqlCommand.Parameters.Add(New SqlParameter("@xID", refID))
Line 385: 'local_sqlCommand.Parameters.Add(New SqlParameter("@xNewTicket", refID))
Line 386: local_sqlCommand.ExecuteNonQuery()
Line 387: local_dbConn.Close()
Line 388: End Sub
error at line 386 :(
this is what i have in my update statement:
Code:
Sub DBUpdateSupportStaffID(ByVal refID As Integer)
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 = "Update ITHelpdesk.dbo.Tickets set SupportStaffID = @xSupportStaffID where ID = @xID"
local_sqlCommand.CommandType = CommandType.Text
local_sqlCommand.Parameters.Add(New SqlParameter("@xSupportStaffID", SupportStaffID))
local_sqlCommand.Parameters.Add(New SqlParameter("@xID", refID))
'local_sqlCommand.Parameters.Add(New SqlParameter("@xNewTicket", refID))
local_sqlCommand.ExecuteNonQuery()
local_dbConn.Close()
End Sub
the primary key ID from the supportstaff table and its a foreign key in my tickets table!
please help me..thanx!(:
-
Re: RowDataBound(:
Where is the supportstaffid coming from? You are passing the id via refID but I do not see anythign that assigns the supportstaffid a value which could mean that it is empty and would likely cause this issue. If it is a public variable assigned elsewhere then maybe it has a value and maybe not but in the code posted there is no assignment.
Ideally supportstaffid should be passed as a parameter into the sub along with the ticketid.
The only other things I can think of is that the staffid assigned is not present in the staff table, or there is a restriction setup on your ticket table to not allow dupes in this column and the staffid is already present in another record.
-
Re: RowDataBound(:
actually everythin works fine except that it doesn't update the ticket table with that new support staff id..i debugged my codes and my the suppoert staff id which the ticket should be assigned to is 70..but the tickets table didnt update that column..the staff table has a record with the staff id 70..
-
Re: RowDataBound(:
Is the ticket table set to allow duplicates in this column? How about your indexes on this table? Are there already records in the ticket table with a staffid of 70? Have you tried using a STaffID that is present in the staff table but not yet used in the tickets table?
-
Re: RowDataBound(:
yess it can allow duplicates..not unique key..ya there is records of that staff id..