SEARCH YOUR SOLUTION HERE  

ASP.NET and VB.NET: problem with GridView's "disabled" b

I have pulled data from SQL Server into a GridView control.
Two of the columns are checkbox fields.

During run-time,I am to click those columns to enter a check.
But how can I find out if the values of those items during run-tim

I need to allow the user to indicate whether they approve or deny a request; and then, I shall be able to update the corresponding columns in the originating database table.

What must I do to solve this problem

During run-time, I added these two columns to the already existing ones:

Dim myCol1 As New DataColumn("Approved") Dim myCol2 As New DataColumn("Denied") myCol1.DataType = System.Type.GetType("System.Boolean") myCol2.DataType = System.Type.GetType("System.Boolean") myDataSet.Tables(0).Columns.Add(myCol1... myDataSet.Tables(0).Columns.Add(myCol2... myDataSet.Tables(0).AcceptChanges()

I have code in myGridView_RowUpdating():

Try 'For Each column As GridViewRow In myGridView.Rows(myGridView.EditIndex) ' Access the CheckBox 'Dim cb As CheckBox = column.FindControl("Approved") 'Perhaps could also check to see if the index of the row equals myGridView.EditIndex For Each row As GridViewRow In myGridView.Rows ' Access the CheckBox Dim cb As CheckBox = row.FindControl("Approved") If cb IsNot Nothing AndAlso cb.Checked Then Console.WriteLine("Found") 'Here, I want to see if the Approved checkbox is checked. End If Next Catch ex As Exception Console.WriteLine(ex.Message) End Try


This is the code that I placed in myGridView_RowCommand():

Static intCount As Integer Dim intRowIndex As Integer 'If intCount = 0 Then intRowIndex = CInt(e.CommandArgument.ToString()) 'dim intColumnIndex as Integer = cint(Request.Form(["__EVENTARGUMENT"]) myGridView.EditIndex = intRowIndex 'Place this particular row of the GridView control in edit mode. intCount += 1 'End If 'If intCount = 0 Dim intResponse As Integer Dim strAnswered As String If (e.CommandName.Equals("Edit")) Then ElseIf (e.CommandName.Equals("Update")) Then Console.WriteLine("Update") ' If myGridView.Rows(intRowIndex).Cells.Item("2").ToString And myGridView.Rows(intRowIndex).Cells.Item("2").Text Then ' End If 'intResponse = MsgBox("Are you sure that you want to approve this request", MsgBoxStyle.YesNoCancel, "Confirmation Required") ElseIf (e.CommandName.Equals("Cancel")) Then Else 'Nada End If 'If (e.CommandName.Equals("Edit")) If intResponse = vbCancel Then MsgBox("The record has not been changed.", MsgBoxStyle.OkOnly, "No Action Taken") Exit Sub End If If intResponse = vbYes Then 'Retreive the value of the key Dim strKey As String 'strKey = myGridView.DataKeys(intRowIndex).Values(0).ToString 'Oops! There has been nothing assigned to DataKeys. 'Note: myGridView.Rows(intRowIndex).Cells.Item(0).Text is "", since it is the column of DELETE buttons. 'This gives the contents of the first row, first column. It would have been Cells.Item(0), had it not been ' displaced by the row of EDIT buttons. strKey = myGridView.Rows(intRowIndex).Cells.Item(1).Text 'Call the handling routine, with strKey as a parameter. 'SupervisorResponse(strKey) End If 'If intResponse = vbYes

Posted On: Saturday 24th of November 2012 02:13:36 AM Total Views:  135
View Complete with Replies




Related Messages:

calling javascript and returning values to vb.net   (261 Views)
Basically I am trying to make a javascript "Ok or Cancel" box and act upon it accordingly.I know that to make a box like that you just need to do this:confirm ("YOUR MESSAGE GOES HERE")So I basically want to do something like this:Code:dim myvarmyvar = confirm("my message")if myvar then' do somethingelse' do something elseend ifI really don't have a clue on how to call the javascript and then to get a value from it.
How to get GridView's imagefield value in vb.net?   (162 Views)
What have you tried so far , You might try converting the databound control into a template field. They are usually a little easier to work with in situations like this, in my opinion. To convert a databound column into a template field you select the little arrow that pops up on the gridview when in design mode and select edit columns. You'll see a list of the column controls on the bottom left, select the one that has the imagefield. beneath the options panel on the right there is a link button that says something like "convert to templated control" or something similar. After you close that wizard you can switch from design view back to code view and that column should look something like in the codebehind you should then be able to do something like Dim img As Image = CType(GridView1.Rows(0).FindControl("Image1"), Image) to get the image control out of the GridView. You should then be able to get what you need from the images properties. I think the above is right but I normally use C# so the syntax could be off on the VB.Net stuff This post has been edited by Nakor: 06 May 2011 - 02:30 PM
Where clause in vb.net 2003   (176 Views)
I am using vb.net 2003. I am just starting to learn programming and I do not know much about it. I am a self taught person so what ever I know is limited and that is the only way I understand. I dont want you to change my whole program. This program is for learning purposes. I need to know the correct syntex for select command with 2 where conditions. Program works fine with one where condition in my select statement I am using Access database Data connection is Microsoft jet 4.0 OLE DB provider Connection conTrainer oldb adaptor - dacust dataset dscust1 table Name - tblCustomerInfo Data set loads fine I need to access table with a select statement with where clause with 2 conditons 1- First Name is from a textbox (user input)txtFirstName.text 2- City from another textbox (user input) txtCity.text datagrid dgrCustomer displays data from this querry on screen My Code Dim mySearchString As String mySearchString = "Select LastName,MI, Address,State, ZipCode, Phone from tblCustomerInfo where FirstName=" & txtFirstName.Text And "city = " & txtcity.Text DsCust1.Clear() daCust.SelectCommand.CommandText = mySearchString dgrCustomers.Refresh() daCust.Fill(DsCust1) Error I am getting An unhandled exception of type 'System.InvalidCastException' occurred in microsoft.visualbasic.dll Additional information: Cast from string "Select LastName,MI, Address,Stat" to type 'Long' is not valid. End Sub
coding for connect to sqlserver from asp.net with vb.net   (172 Views)
coding for connect to sqlserver from asp.net with vb.net
Sending automatic emails - asp.net with vb.net and sql server express   (178 Views)
I am developing a website which needs to send out an email every saturday to in the database. I have the code to send an email when a button is clicked, I just don't know how to send one with out clicking a button. Help would be really appreciated!
Images insert and retrive in asp.net use vb.net language   (195 Views)
i want to create a website in asp.net using vb language. this website is fully image base website . and in this website users him self upload his own images and its show in the collaction page i m using asp.net 2.0 in vb and sqlserver 2005 as database
display calculation answer in vb.net/asp   (216 Views)
I have made a program that a user insert 2 number each in a texbox, now i want to calculate the 2 numbers and display them. I've already made the asp code, and i'm stuck on the displaying in the vb code. i've try to use the messagebox.show but it gives me an error here is my code so far: Partial Class _Default Inherits System.Web.UI.Page Protected Sub btn2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn2.Click Dim calculation As Double calculation = numb1.Text / (numb2.Text + numb2.Text) System.Windows.Forms.MessageBox.Show(calculation) End Sub End Class
Importing data direct from vb.net   (147 Views)
I've generated 2 numbers using a small VB algorythm into a VB Textbox. Now, while using ASP.net, how do I print those numbers onto my web page, ie, getting the web page to look directly at those numbers ps, sorry for my noobieness.
Dll in vb.net vs asp.net   (166 Views)
Hi , I have a dll file which represents a control(Player) for listing mp3 or wav files. I have a doubt when add this dll to vb.net app it displays the control but when I use the same to asp.net form I don't get any control and when I tried to display the control thought coding I failed as I am not aware of the code I jst wan know why is this dicrepany in windows and web application.....................
Make a custom vb.net dropdown list?   (145 Views)
Can someone help me I need to add a number of dropdown lists to my web page but I dont know how many I have to add before I load the page.So I someone have an example on how to add number of dropdown list with an action when something is selected I will be very grateful.
open doc file in richtextbox using dialogbox in vb.net   (350 Views)
here i wana open a doc file in richtextbox using openfiledialogboxin vb.net if any one can help me then help me its urgent
Error in calculating irr in asp.net and vb.net   (181 Views)
i am calculating irr and pass listarray created at runtime to irr function and i get error. as i'm new to .net i have to calculate irr textbox2.text specify the no installments textbox1.text specify loan amount textbox5.text specify the amount of installments Dim i As Int16 Dim pay As New ArrayList() For i = 0 To TextBox2.Text pay.Add(TextBox5.Text) Next pay.Add(-TextBox1.Text) Dim ir As Double ir = Math.Round(Microsoft.VisualBasic.Financial.IRR(pay (TextBox2.Text + 1), 0.1), 2) TextBox7.Text = ir GET THIS ERROR MESSAGE Unable to cast object of type 'System.Double' to type 'System.Double[]'.
how to export gridview inside textbox to excel using vb.net   (217 Views)
i can export only the label column not in the textbox column. code behind in vb.net for export the gridview to excel: Response.Clear() Response.AddHeader("content-disposition", "attachment;filename=FileName.xls") Response.Charset = "" Response.Cache.SetCacheability(HttpCacheability.NoCache) Response.ContentType = "application/vnd.xls" Dim stringWrite As System.IO.StringWriter = New System.IO.StringWriter() Dim htmlWrite As System.Web.UI.HtmlTextWriter = New HtmlTextWriter(stringWrite) GridViewClassification.RenderControl(htmlWrite) Response.Write(stringWrite.ToString()) 'Response.Flush() Response.End()
Write in XML file, asp.net vb.net   (251 Views)
! Well I have an aplication in asp.net vb.net, and I want to save something important writing in a xml file, but I want to write in this way: (key,value). In this momento I can write in comments, but I couldn't find the way to write with values and keys. If somebody can help me, would be great! This is my code: Imports System.Xml Dim textWriter As XmlTextWriter = New XmlTextWriter("C:\\myXmFile.xml", Nothing textWriter.WriteStartDocument() textWriter.WriteComment("My important thing") textWriter.WriteComment("myXmlFile.xml in root dir") textWriter.WriteEndDocument() Thank you!
Make EPS file in vb.net code   (146 Views)
I would like to make an Eps File in Vb.net Code. When I open an eps file in textpad it looks like a programming language. Is this language like Html Any Help with Understand an Eps file will be Great
How to create social networking site using vb.net 2008   (124 Views)
A peaceful 2009 to ! How could i create a social networking site using visual basic.net 2009, i will need reports as administrator, kindly email your answer to {REMOVED}. Thank you and God bless=) Attached image(s)
Error in calculating irr in asp.net using vb.net   (115 Views)
i am calculating irr and pass listarray created at runtime to irr function and i get error. as i'm new to .net i have to calculate irr textbox2.text specify the no installments textbox1.text specify loan amount textbox5.text specify the amount of installments Dim i As Int16 Dim pay As New ArrayList() For i = 0 To TextBox2.Text pay.Add(TextBox5.Text) Next pay.Add(-TextBox1.Text) Dim ir As Double ir = Math.Round(Microsoft.VisualBasic.Financial.IRR(pay (TextBox2.Text + 1), 0.1), 2) TextBox7.Text = ir GET THIS ERROR MESSAGE Unable to cast object of type 'System.Double' to type 'System.Double[]'.
How to shut down the computer using asp.net and vb.net   (111 Views)
here is my code but it not working Partial Class _Default Inherits System.Web.UI.Page Private Sub btnRestart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRestart.Click System.Diagnostics.Process.Start("shutdown", "-r -t 50") 'This will make the computer Restart End Sub Private Sub btnLogOff_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogOFF.Click System.Diagnostics.Process.Start("shutdown", "-l -t 50") 'This will make the computer Log Off End Sub 'Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click ' 'End '' 'This will make the program to terminate(end the program) 'End Sub Protected Sub btnShutdown_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnShutdown.Click System.Diagnostics.Process.Start("shutdown", "-s -t 50") 'This will make the computer Shutdown End Sub End Class This post has been edited by PsychoCoder: 21 December 2007 - 01:32 PM
transfer aplication from vb.net to asp.net   (253 Views)
hi.. i'm newbie in programing. so, please help me.. I design an applet for desktop with vb.net, and i want to use this applet for web application with asp.net. Can't i transfer this applet to web app, and how to do that
Web Services vb.net   (324 Views)
I am unsure how to cast from integer to string if that is even what is required. ID field in db is Integer. I can't seem to find any relevant advice, and also I followed the video step by step, using Access 2007 vs. SQLServer and VWD2010, so no AJAX enabled site option available, but I have included everything needed as far as I know: Imports System.Web Imports System.Web.Script.Services Imports System.Web.Script.Services.ScriptMethodAttribute Imports System.Web.Services Imports System.Web.Services.Protocols Imports AjaxControlToolkit Imports System.Data Imports System.Data.OleDb Imports System.Data.OleDb.OleDbConnection Imports System.Configuration Imports System.Collections Imports System.Collections.Generic Imports System.Collections.Specialized _ _ _ _ Public Class SPGSvc Inherits System.Web.Services.WebService _ _ Public Function GetSPG(ByVal knownCategoryValues As String, ByVal category As String) As CascadingDropDownNameValue() Dim spgAdapter As New dsSPGTableAdapters.SPGsTableAdapter Dim spgValues As New List(Of CascadingDropDownNameValue)() For Each row As DataRow In spgAdapter.GetSPG() spgValues.Add(New CascadingDropDownNameValue(row("SPG").ToString(), row("SPGID").ToString())) Next Return spgValues.ToArray End Function _ Public Function GetFLOW(ByVal knownCategoryValues As String, ByVal category As String) As CascadingDropDownNameValue() Dim kv As StringDictionary = CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues) Dim SPGID As Integer If ((Not kv.ContainsKey("SPG")) Or (Not Int32.TryParse(kv("SPG"), SPGID))) Then Return Nothing End If Dim flowAdapter As New dsFLOWTableAdapters.FlowsTableAdapter Dim flowValues As New List(Of CascadingDropDownNameValue)() For Each row As DataRow In flowAdapter.GetFLOW(SPGID) flowValues.Add(New CascadingDropDownNameValue(row("FLOW").ToString(), row("SPGID").ToString())) Next Return flowValues.ToArray End Function End Class This post has been edited by miweiser: 13 May 2010 - 10:47 AM