Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > why does this formview not appear?

Reply
Thread Tools

why does this formview not appear?

 
 
Cliff
Guest
Posts: n/a
 
      02-14-2007
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>


 
Reply With Quote
 
 
 
 
Bruno Alexandre
Guest
Posts: n/a
 
      02-14-2007
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" <> wrote in message
news:%...
> 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>
>
>


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Formview within Formview Chris ASP .Net 0 05-19-2007 04:12 PM
why does this formview not appear? Cliff ASP .Net 1 02-14-2007 08:29 PM
why why why why why Mr. SweatyFinger ASP .Net 4 12-21-2006 01:15 PM
findcontrol("PlaceHolderPrice") why why why why why why why why why why why Mr. SweatyFinger ASP .Net 2 12-02-2006 03:46 PM
FormView/Repeater/ Eval(FormView data) David Thielen ASP .Net Web Controls 2 06-16-2006 07:56 PM



Advertisments