|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Formview child control data retrievalGuys,
I need help with the FormView control. I have read alot of posts about retrieval of data from child control but I am failing. for some reason. I am trying to get the data so I can use the FormView to eit the data and update I had to put the link buttons and everything. Everything is working. And I can see the data in Textbox, but it is throwing an exception to check for a null, and I know for sure it not null cos I am binding the value to it. I am including the code that I am using to retrieve value from fromview and this exapmple I have picked up by one of the posts that actually discusses an issue. Can you please guide me in this regard. Any Help will be appreciated. Thanks, Dim some As New TextBox some = CType(FormViewNotes.Row.FindControl("TxtBoxEdt1"), TextBox) ' Response.Write(some.Text) hi geek, for me it works. What are you doing differently from the small test
below. As you can see, I am able to retrieve the value in the page_load phase itself, and the value is output to screen. By the way, there is a good example on msdn, on how to update using the formview control. Here is the reference : http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.formview.itemupdated.aspx Regards, Alessandro Zifiglio http://www.AsyncUI.net <%@ Page Language="VB" %> <%@ Import Namespace="System.Data" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) If (Not Page.IsPostBack) Then Dim values As New ArrayList() values.Add("Apple") FormView1.DataSource = values FormView1.DataBind() End If ' Use the Row property to retrieve the data row from ' the FormView control. Dim row As FormViewRow = FormView1.Row Dim tb1 As TextBox = CType(row.FindControl("TextBox1"), TextBox) If (tb1 IsNot Nothing) Then Response.Write("<br /> Found textbox1 value in Page_Load phase : " & tb1.Text) End If End Sub </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>Untitled Page</title> </head> <body> <form id="form1" runat="server"> <div> <asp:FormView ID="FormView1" runat="server"> <ItemTemplate> <asp:TextBox ID="TextBox1" Text='<%# Container.DataItem %>' runat="server"></asp:TextBox> </ItemTemplate> </asp:FormView> </div> </form> </body> </html> This is the output i get in the rendered page : Found textbox1 value in Page_Load phase : Apple Show quoteHide quote "Geek" <corr***@hotmail.com> ha scritto nel messaggio news:1153255612.317408.109730@h48g2000cwc.googlegroups.com... > Guys, > > I need help with the FormView control. I have read alot of posts about > retrieval of data from child control but I am failing. for some reason. > I am trying to get the data so I can use the FormView to eit the data > and update I had to put the link buttons and everything. Everything is > working. And I can see the data in Textbox, but it is throwing an > exception to check for a null, and I know for sure it not null cos I am > binding the value to it. I am including the code that I am using to > retrieve value from fromview and this exapmple I have picked up by one > of the posts that actually discusses an issue. Can you please guide me > in this regard. Any Help will be appreciated. Thanks, > > Dim some As New TextBox > some = CType(FormViewNotes.Row.FindControl("TxtBoxEdt1"), > TextBox) > ' Response.Write(some.Text) > Dear Alessandro Zifiglio ,
I finally got it to working it is pretty easy. I thought I can access control any time in a container regardless of the mode of the containeer. What I did is first I replicate all the controls I need name em same, as they are in ItemTemplate and then later retrievd them after changing mode I really appreciate your help on this. Thanks,
passing data on the cleint side
onTextChanged won't fire in UserControl GridView, ObjectDataSource, Update problems. Add a control to a treenode. TreeView Windows control in .ASPX page .Net 2.0 - WebBrowser control embedded in IE causes problems Commenting Out Controls In HTML View Autopostback and submit button Client-side web control/.NET based Java applets possible? Register clientscript resource |
|||||||||||||||||||||||