Datagrid(.net 1.1) to GridView(.net 2.0) and using the RowUpdating event how to extract the values from the controls.


 This is the settings:

I use a Viewgrid with only itemtemplate colums for example.


asp:TemplateField HeaderText="Test"><ItemTemplate><asp:Label id="LBL_Test" text='<%# DataBinder.Eval(Container.DataItem, "Test1") %>' runat="server" meta:resourcekey="LBL_TestResource1"></asp:Label></font></ItemTemplate>

<EditItemTemplate><asp:TextBox ID="HDN_Test" Text='<%# DataBinder.Eval(Container.DataItem, "Test1") %>' Runat="server" meta:resourcekey="HDN_TestResource1" /></EditItemTemplate></asp:TemplateField>

 The viewgrid is not in any way bound to a datasource and I want to manually extract values from the datagrid when a update event occurs and then manually set/update the new values in the database (using procedures).

Now I have tried several ways of getting the new values of the controls that are in the gridview control but are still just getting old values. Have been searching the net for solutions use..

Some examples of code tried.(old code, msdn example code, other kinds of code).

Sub UpdateClick(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewUpdateEventArgs)


test As String

test =

CType(GridView1.Rows(e.RowIndex).Cells(2).Controls(1), TextBox).Text()


"Value" & test)

 --Another way--


 newvalue As Integer = _

CType(GridView1.Rows(e.RowIndex).FindControl("HDN_Test"), TextBox).Text()


--Another way-- 


gv As GridView = GridView1

Dim i As Integer = 0

While (i < GridView1.Columns.Count)

Dim cell As DataControlFieldCell = gv.Rows(e.RowIndex).Cells(i)

gv.Columns(i).ExtractValuesFromCell(e.NewValues, cell, DataControlRowState.Edit,



i = i + 1

End While

-- Another Way--

Dim index As Integer = GridView1.EditIndex

Dim row As GridViewRow = GridView1.Rows(index)


Dim lastName As TextBox = CType(row.FindControl("HDN_test"), TextBox)

Dim firstName As TextBox = CType(row.FindControl("HDN_test1"), TextBox)




GridView1.EditIndex = -1


End Sub

So what am I missing ?!?!  Works great with the datagrid but not with GridView.

Could anybody provide some ideas... code examples .... anything..

4/30/2007 5:50:25 PM 72751 articles. 3 followers. Follow

3 Replies

Similar Articles

[PageSpeed] 11
Get it on Google Play
Get it on Apple App Store


I have a CheckBox in a TemplateField in one of my GridViews. You should be able to figure out what you need to do from my code below:

Protected Sub GridRowCheckBox_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs)

        ' Get the CheckBox that triggered the event
        Dim cb As CheckBox = CType(sender, CheckBox)

        ' Get the row the CheckBox is part of so we can retrieve values
        Dim row As GridViewRow = CType(cb.NamingContainer, GridViewRow)

        ' First off, get the row id field value, which is use as the key for 
        ' whether or not the checkbox row is already being tracked
        Dim key As Integer = Integer.Parse(row.Cells(1).Text)

        ' See if the checkbox was checked
        If (cb.Checked) Then

            ' See if this row has already been accounted for in the collection
            If Not (Me.CheckedItems.ContainsKey(key)) Then

                ' Add this key and the row values to the checkeditems collection
                Me.CheckedItems.Add(key, New Employee(key, row.Cells(2).Text, row.Cells(3).Text))

            End If

        End If

    End Sub
ASP.NET Weblog

Personal Blog

My Business
4/30/2007 7:09:37 PM

Thanks for the answer, might be the solution.

But do you in other words say that I need a handler for every different type of Itemtemplate so that each of them can catch changes for each column edited ?

Didn't need to use this in a custom datagrid design, then all the data was retrieved in the update event.

4/30/2007 9:00:49 PM

No, I didn't mean to say that you need a handler for every ItemTemplate control you put in. What I was attempting to do was to give you some code that would show to how to grab the variables from the row on your Update function.

I think you should be able to use the above code in your Update event, grab all of the values you need and then use them as needed.

Hope that helps.


ASP.NET Weblog

Personal Blog

My Business
4/30/2007 10:28:16 PM

Similar Artilces:

Differences between .net 1, .net 1.1, .net 2.0 and .net 3.0 #2
Hi, This seems to be a common question, but i havent got an answer yet:(Can, any one please explain me the differences between these versions.If you keep your feet firmly on the ground, you'll have trouble putting on your pants! There are too many differences for one email - - from 1.0 to 1.1 (not a whole lot of real change, other than fixes, at least compared to 1.1 to 2.0) With 2.0, there were many new declarative controls, with many new ideas added in With 3.0, it's a superset of 2.0 - instead of replacing the installation completely, it just 'added on' new functionality - I would...

Differences between .net 1, .net 1.1, .net 2.0 and .net 3.0
Hi, This seems to be a common question, but i havent got an answer yet:(Can, any one please explain me the differences between these versions.If you keep your feet firmly on the ground, you'll have trouble putting on your pants! Have a look into this links Rajawww.iGold.inDon't forget to click "Mark as Answer" on the post that helped you. This credits that m...

Running server controls compiled for .NET 1.1 in .NET 2.0
Hello, I have tried upgrading our ASP.NET 1.1 application to .NET 2.0 by using Web Application Projects, and it works beautifully. We use several 3rd party controls that we bought for use in .NET 1.1 and these seem to just work in .NET 2.0, except that I get an intermittent problem with one of them. Should DLLs compiled using .NET 1.1 simply work, except if they access classes that have been removed from the framework in .NET 2.0? If I have both .NET 1.1 and .NET 2.0 present on the machine and the ASP.NET application is configured to run using .NET 2.0 and I have a DLL compiled using .NE...

Using .net 2.0 ws in .net 1.1
Hi,I have a ws written in 2.0 that returns a dataset. I need to use this ws in .net 1.1. Seems like having the ws returning typed datasets causing a problem.I am using c# for the ws. Does anyone have any idea ? Any suggestion would be appreciated. Thanks, recruit A web service should be indifferent to which version of ASP.NET is producing and which version is consuming. Please post any error messages and the wsdl produced by the 1.1 consumer. Have you loaded WSE 3.0 ( and mon...

Using .NET 1.1 dll in .NET 2.0
I have my old application on Visual Studio 2003, now we are planning to migrate to Visual Studio 2005, so is there a way to use my old dlls as references that were built using .NET Framework 1.1 in a new application that will be built using .NET Framework 2.0? I also have a question regarding the posibility to build code that was written in Visual Studio 2003 environment using .NET Framework 2.0 compiler?Mohammad Abu-AliMicrosoft Certified Professional Hi, Yes you can use your .NET 1.1 dll in your 2.0 app (but the other side is not true) For the last question, there is great chance...

Migrate DataGrid .NEt 1.1 to .NEt 2.0
Hi I has just convert my ASP.NET web application from .NET 1.1 to .NEt 2.0 so far there is no problem but my datagrid seems to be acting really weird my datagrid has 3 columns and have paging enabled. When there is one/two row of data. The paging(which shows us the number of page) seems to have a column span of 1)  If i click on the second row of data.... the paging will have the column span of 3 This does not happen if there is more than 2 data   please go to the link for better clarification http://ying...

Where is the ADO.NET Sybase driver for .NET 1.1 and .Net 2.0?
Hi All Does anyone know where I can get the Sybase drivers for ADO.NET for both versions, 1.1 and 2.0/3.0? Cheers Chris Burrell Hi Chris, There is no release of ASE ADO.NET Provider 2.0 (I assume you refer to ASE provider, not ASA - if ASA please port to sybase.public.sqlanywhere.general). For the 1.1 Provider: It is available in the ASE SDK for windows or the PC Client CDRom included with ASE product. On the SDK its available as 12.5.1 and 15.0 On ASE PC Client I think 12.5.1 is part of ASE 12.5.X and 15.0 is part of ASE 15.X 2.0 provider should release som...

.net 2.0 to .net 1.1
Hello , This is shrirang. Currently i am working .net2.0 web application. but the same application is runing on production in .net 1.1 freamwork . we are not using any new feature of 2.0 in our application . can i run build of 2.0 on 1.1 freamwork . if yes can you  please tell me necessary steps to achive it .     Thanks in advance for your kind help     Regards Shrirang i think it is not possible to run the 2.0 application in 1.1 , so try to change to the frame work in the production server . ThanksRaja Ragothaman Hi Shrirang, Please contact web adm...

having .net 1.1 and .net 2.0
Was just wondering if you someone could tell me the ramifications of the following:  I have .net 2.0 but did not uninstally .net 1.1, i have visual studio 2003, and visual web developer installed on the computer as well as sql server 2000.  my question is whether that is a problem having the two runtimes installed at the same time?  i did this because i wanted to use VWD but keep vs 2003 in case i needed to do any development for work....any comments are appreciated.  --jpIf my post is helpful please mark as answerRegards -- jp(

How to use .net 1.1 on webserver after adding .net 2.0 Framework
I have a web server with .net 1.1 installed on it. I am going to install the .net 2.0 framewrok on my server. How can I select the .net 1.1 framework for my existing applications that are already using 1.1 after I install 2.0. Someone told me about going onto IIS and in the properties there is a tab to select the version of .net, I have looked at this but it there is no tab to choose .net version, my web server is ms server 2000. Anyone any idea how to do this? Thanks macca macca:Someone told me about going onto IIS and in the properties there is a tab to select the version of .net, I...

How to get new web app to use .NET 2.0 on Win2K server using .NET 1.1 as default framework?
I have .net framework1.1 and 2.0 on our server running win2K. i have existing applications that uses 1.1, i also have a new app that use 2.0.  how can i set my new .NET 2.0 app to point to 2.0 without messing up my existing .NET 1.1 apps? To specify the ASP .Net version fro a web application, do the followingIn IIS Manager select the web application -> Properties -> ASP.Net TabSelect  ASP.Net version you want to use for the applicationRegards,PrashantDont forget to click "Mark as Answer" on the post that helped you. But I am running Win2K...

Any advantages of migrating to .NET 2.0 on still using .NET 1.1 projects?
Sorry for the noob Q - but will I get any advantages in installing .NET 2.0 Framework alongside .NET 1.1 if I dont plan to upgrade my ASP .NET 1.1 web applications?I have a few servers that I will be installing the .NET 2.0 Framework so as to develop in VS2005, however on some servers that will not (at this stage) be used for .NET 2.0 apps and that I may not have the time to convert some VS2003 applications to VS2005, I was in the 'if it aint broke, dont fix it' kind of thinking and didn't know if installing .NET 2.0 would bring any advantages.TIA.  I happen to agree. If you don't nee...

.DLL compiled with .NET 1.1 to be used in Web app done in .NET 2.0
Hi all,If I have a bunch of business objects that where compiled in .NET version 1.1, would it be possible for my ASP.NET (done in .NET 2.0) application to pick up these objects (.dll file) and start to use them?(Would be great if some-one could provide some form of documentation on this)ThanksTryst Hi Tryst, This should work fine.  In general, you can use V1.1 assemblies with V2.0 applications.  The reverse, though, is not true. Hope this helps, Scott ok, cool.ThanksTryst Comparative study on VS .Net 2003 and VS.Net 2005 .Net Framework versions used are ver...

.Net 1.1 and .Net 2.0 on the same webserver ?
Hi allCan you run .Net 1.1 and .Net 2.0 on the same webserver ? Does anybody do this currently and does both DNN 3.1.1 and the new dnn 4.0 work ok on this configuration ?/JohanFirstDev AB Affä Yes, and Yes.John M. to elaborate a bit on that: yes, if you are using windows server 2003. You can select the .net version on a per application basis, however, you can only use one .net version per application pool. So just put your .net 2.0 applications in a different poolcheers,erikErik van Ballegoij, The Netherlands You can do it on XP Pro, or Windows 2000 Server also, you ...

Web resources about - Datagrid(.net 1.1) to GridView(.net 2.0) and using the RowUpdating event how to extract the values from the controls. -

Resources last updated: 1/22/2016 7:28:27 AM