|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Cant get user-entered values in GridViewtotally obvious, but i cannot figure this out. I did this all the time in ASP.NET 1.1 with no problems. I have a GridView which has a column that is a template column, and has a textbox in the itemtemplate. There is one button in the footer of the grid for "save"; so the user can type in changes to a bunch of rows, and then click save, and my code iterates essentially as so: For Each gr As GridViewRow In grid.Rows: SaveRow(gr): Next This way they can change a bunch of rows and then save instead of doing change a row, save, change a row, save, change a row, save, change a row, save. So my code (pseudo-code) looks like this: Sub btnSave_Click For Each gr As GridViewRow in grid.Rows Dim newValue as string = CType(gr.FindControl("txtValue"),TextBox).Text Dim SQL as string = "Some Sql using the new value" ExecuteSQL Next End Sub The problem is, when i get the Text property from the textbox, it gives me the OLD value to which it was initially bound, instead of giving me the new value which the user typed in. Why? How am i supposed to get the user's new data? Please HELP!! Thanks in advance, - Arthur Dent Hi,
Try it... http://www.dotnetjohn.com/articles.aspx?articleid=83 It looks what you are looking for... best luck ... Show quoteHide quote "Arthur Dent" <hitchhikersguideto-n***@yahoo.com> wrote in message news:ur06xYtRGHA.2276@tk2msftngp13.phx.gbl... > Okay, this should be really simple, and maybe im just missing something > totally obvious, but i cannot figure this out. I did this all the time in > ASP.NET 1.1 with no problems. > > I have a GridView which has a column that is a template column, and has a > textbox in the itemtemplate. There is one button in the footer of the grid > for "save"; so the user can type in changes to a bunch of rows, and then > click save, and my code iterates essentially as so: > > For Each gr As GridViewRow In grid.Rows: SaveRow(gr): Next > > This way they can change a bunch of rows and then save instead of doing > change a row, save, change a row, save, change a row, save, change a row, > save. > > So my code (pseudo-code) looks like this: > > Sub btnSave_Click > For Each gr As GridViewRow in grid.Rows > Dim newValue as string = > CType(gr.FindControl("txtValue"),TextBox).Text > > Dim SQL as string = "Some Sql using the new value" > ExecuteSQL > Next > End Sub > > The problem is, when i get the Text property from the textbox, it gives me > the OLD value to which it was initially bound, instead of giving me the > new value which the user typed in. Why? How am i supposed to get the > user's new data? > Please HELP!! > > Thanks in advance, > - Arthur Dent > Check to see if you've over written your gridview values in the events
before getting to your postback event handler (btnSave_Click()) and after ASP.NET calls LoadViewState (eg. Page_Load()). Yes, this was it.... in my Page_Load, i have my "If Not IsPostBack" block
commented out, ... why, who knows. Uncommented that, and now it works as perfect. Thanks for the "extra set of eyes"! CheerZ! <CaffieneR***@gmail.com> wrote in message Show quoteHide quote news:1142340399.248123.158930@i39g2000cwa.googlegroups.com... > Check to see if you've over written your gridview values in the events > before getting to your postback event handler (btnSave_Click()) and > after ASP.NET calls LoadViewState (eg. Page_Load()). >
argumentoutofrangeexception using detailsview
RadioButtonList, MultiView, and JavaScript DropDownList select: first visible a label, then post back ASP.NET, CSS, and Netscape 7.1 Detailsview with command field displayed as button Fitting a character on a small button GridView Multiple Select Buttons Passing values between user controls in separate forms Menu control MenuItemClick does not fire. it's really important thing to solve |
|||||||||||||||||||||||