473,396 Members | 1,814 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

messagebox for validation onrowupdating in gridview

2
Expand|Select|Wrap|Line Numbers
  1. Protected Sub GridView1_RowUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles GridView1.RowUpdating
  2.  
  3.         ' ''Dim role1 As String
  4.  
  5.         ' ''role1 = e.NewValues(0).ToString
  6.  
  7.         'string myLastName = e.NewValues[1].ToString();
  8.  
  9.  
  10.  
  11.         ' Dim tb As TextBox = GridView1.Rows.Item(e.RowIndex).FindControl("txt_role")
  12.  
  13.         'Dim role_name As String
  14.  
  15.         'role_name = tb.Text
  16.  
  17.  
  18.         Dim str1, str2 As String
  19.         Dim ds1, ds2 As New DataSet
  20.  
  21.         lobId = DropDownList1.SelectedItem.Value
  22.         duId = DropDownList2.SelectedItem.Value
  23.         projectId = DropDownList3.SelectedItem.Value
  24.         roleId = DropDownList4.SelectedItem.Value
  25.  
  26.  
  27.  
  28.  
  29.         Dim sID As String = GridView1.DataKeys(e.RowIndex).Values(0).ToString
  30.  
  31.         Dim txt_role As TextBox = CType(GridView1.Rows.Item(e.RowIndex).FindControl("txt_role"), TextBox)
  32.  
  33.         Dim rolename As String = Convert.ToString(txt_role.Text)
  34.         GridView1.EditIndex = -1
  35.         GridView1.DataBind()
  36.  
  37.         Dim cnt As Integer
  38.         str1 = "SELECT COUNT(*) FROM role  WHERE (role = '" & rolename & "' and role.project_id='" & projectId & "' )"
  39.  
  40.  
  41.         da1 = New SqlDataAdapter(str1, con)
  42.         da1.Fill(ds1)
  43.         cnt = (ds1.Tables(0).Rows(0).Item(0))
  44.  
  45.         If (cnt >= 1) Then
  46.             'flag = True
  47.  
  48.             MsgBox("role exists, enter different")
  49.  
  50.             txt_role.Text = ""
  51.             txt_role.Focus()
  52.  
  53.             Exit Sub
  54.  
  55.         Else
  56.             'GridView1.UpdateRow(0, True)
  57.  
  58.             str2 = "update role set role = '" & rolename & "'   where  role_id = '" & roleId & "' and  project_id = '" & projectId & "' "
  59.  
  60.             da2 = New SqlDataAdapter(str2, con)
  61.             da2.Fill(ds2)
  62.  
  63.         End If
  64.  
  65.  
  66.     End Sub
I want to check that the same role is not entered, but the problem is that it displays the messagebox on repitition of values but still updates the repeated values in the database
Oct 6 '08 #1
0 904

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: kannan | last post by:
hi, It might be the simple question. I am concatinating two string and displaying in messagebox. Ex: MessageBox.show(string.Concat("The following validation(s) failed:\n", arg.DisplayMessage))...
1
by: wei | last post by:
Hello all this is problem I worked a few hours without answer, this is my gridview control------- <asp:GridView ID="gview" runat="server" Width="710px" AutoGenerateEditButton =true ...
0
by: =?Utf-8?B?cm9kY2hhcg==?= | last post by:
hey all, i have a gridview where i need to do some custom validation. i'd like to extract the validation procedure as much as i can. so what i'm doing is whenever a user selects save i call the...
2
by: Sheena777 | last post by:
How do you cause the validations to occur on a gridview I can't seem to cause the validation to happen. I am saving a record to a database from the gridview I want to check the values before they are...
0
by: senglory | last post by:
I have the following ASPX: <asp:GridView ID="ctlAllocations" runat="server" OnRowEditing="ctlAllocations_OnRowEditing" OnRowDeleting="ctlAllocations_OnRowDeleting"...
0
by: Jeff | last post by:
hi asp.net 2.0 I'm having problem updating a GridView. The problems is that the website complains it don't find the update method. The problem is caused by the updateparameters. The...
12
by: btreddy | last post by:
Hii Experts, im facing a problem with the javascript validation.i've a gridview in my web form and added a footer tempalte and placed textboxes in tht tempalte ,just to add a new row to the...
2
by: mrutyunjaya | last post by:
hello, i have two textbox column and one button control in gridvie when i click button it will ask plese enter price in first textbox . when enter values it is asking again. how to pass...
0
parshupooja
by: parshupooja | last post by:
hey all, I have DataTable binded to Gridview . This Datatable contains Data from Database. Before binding it to Gridview I am adding extra line with few controls dynamically in it such as text...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.