473,394 Members | 1,813 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,394 software developers and data experts.

why does this formview not appear?

Hi,

I expect with this code to see the FormView in the browser but nothing
appears (no error, no formview).
I checked with variable 'x' and i know there is one record in the dataset.
The formview must be editable.

Did i forget something?
Thanks for help.
code-behind:
-----------
Dim ds As DataSet
Dim d As SqlDataAdapter
Dim sql As String
Dim sConnectionString As String
Dim x As Integer

sConnectionString =
System.Configuration.ConfigurationManager.Connecti onStrings("aspnetdb").ToString()
'in web.config
sql = "SELECT field1, field2 FROM table1 where ....
d = New SqlDataAdapter(sql, sConnectionString)
ds = New DataSet()
x = d.Fill(ds) 'this gives 1 record
FormView1.DataSource = ds
FormView1.DataBind()

aspx file:
---------
<form id="form1" runat="server">
<asp:FormView ID="FormView1" runat="server">
<EditItemTemplate>
<asp:Label ID="Label1" runat="server"
Text="username:"></asp:Label>
<asp:TextBox runat="server" Text='<%# Eval("field1") %>' >
</asp:TextBox>
<br />
<asp:Label ID="Label2" runat="server" Text="your age:"></asp:Label>
<asp:TextBox ID="TextBox2" runat="server" Text='<%# Eval("field2")
%>'>
</asp:TextBox>
</EditItemTemplate>
</asp:FormView>
</form>
Feb 14 '07 #1
1 3358
from the code, that will never show you the editable part !
cause, and please see the code, where is the line that you say the FormView
to be in EDIT mode ???
by default it always show the ITEM mode!

<asp:FormView ID="FormView1" runat="server" DefaultMode="Edit">

and by the way, please write a proper code (this s just a sugestion to build
a cleaner code):

Imports System.Data
Imports System.Data.SqlClient

---

Using Connection As New
SqlConnection(ConfigurationManager.ConnectionStrin gs("aspnetdb").ConnectionString)
Dim ad As New SqlDataAdapter("SELECT * FROM TableName... ",
Connection)
Dim ds As New DataSet()
ad.Fill(ds, "TableName")

FormView1.DataSource = ds
FormView1.DataBind()
End Using

The Using will close all the open objects so you do not need to close after
using them.

--

Bruno Alexandre
Stroby, Danmark

"a Portuguese in Denmark"
"Cliff" <cl***@no.cvwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
Hi,

I expect with this code to see the FormView in the browser but nothing
appears (no error, no formview).
I checked with variable 'x' and i know there is one record in the dataset.
The formview must be editable.

Did i forget something?
Thanks for help.
code-behind:
-----------
Dim ds As DataSet
Dim d As SqlDataAdapter
Dim sql As String
Dim sConnectionString As String
Dim x As Integer

sConnectionString =
System.Configuration.ConfigurationManager.Connecti onStrings("aspnetdb").ToString()
'in web.config
sql = "SELECT field1, field2 FROM table1 where ....
d = New SqlDataAdapter(sql, sConnectionString)
ds = New DataSet()
x = d.Fill(ds) 'this gives 1 record
FormView1.DataSource = ds
FormView1.DataBind()

aspx file:
---------
<form id="form1" runat="server">
<asp:FormView ID="FormView1" runat="server">
<EditItemTemplate>
<asp:Label ID="Label1" runat="server"
Text="username:"></asp:Label>
<asp:TextBox runat="server" Text='<%# Eval("field1") %>' >
</asp:TextBox>
<br />
<asp:Label ID="Label2" runat="server" Text="your
age:"></asp:Label>
<asp:TextBox ID="TextBox2" runat="server" Text='<%# Eval("field2")
%>'>
</asp:TextBox>
</EditItemTemplate>
</asp:FormView>
</form>

Feb 14 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: John Bailey | last post by:
When I first built a few web pages in ASP .Net 2.0, I thought it was great. The formview and detailview contorls would automatically layout the controls for you, the update methods were...
3
by: sck10 | last post by:
Hello, I am creating a form for users to enter information about a lab and the members of the lab. I have one form (FormView) that they use to enter information about that lab. The keyvalue is...
7
by: Lorenzino | last post by:
Hi, I have a problem with bindings in a formview. I have a formview; in the insert template i've created a wizard control and inside it i have an HTML table with some textboxes bound to the...
3
by: Geek | last post by:
Guys, I am working on a project, and I thought using FormView will help good but I am running into a issue. What I have done is that in Form View in Footer template icluded a Link Button which...
2
by: sck10 | last post by:
Hello, I have 3 objects: LinkButton GridView FormView The LinkButton is used to open the FormView in Insert mode. The GridView provides a list of products. When the "Select" link is
5
by: Mark Olbert | last post by:
It appears that FormView controls require the >>exact<< same layout of controls and control types in the various templates in order to function properly. Failure to do so results in a "failure to...
1
by: Dave | last post by:
When a user logs into my site, a row for order info is inserted into an MDB table. The next page uses a databound control that references the quantity in that newly created row. Is it possible...
6
by: jobs | last post by:
This code was working, but then stopped working. I don't think I completely understand it. I pass it a formview name and it would loop through checking the value of textboxes. problem is...
0
by: COHENMARVIN | last post by:
I have a sqldatasource and a formview. I bind the formview to the sqldatasource, and hope that automatically the fields of the select statement in the datasource will appear in the itemtemplate of...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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.