FORMVIEW CONTROL

D

DENTONE

Hi,



I have added a formview to my asp.net page

and i have ad this code:

------------------------------------------------------------------------------------------------------------------------------------------------

FormView1.DataSource = leggidatinave(Session("agenzia"), Session("nave"),
Session("porto"))

FormView1.DataBind()



Public Function leggidatinave(ByVal agenzia As String, ByVal nave As String,
ByVal porto As String) As DataTable

' Dim connstring As String = "Data Source=[server];Initial
Catalog=[master];User ID=[HACPACK];Password=[francesca]"

Dim connstring As String = "Data Source=serverhacpack;Initial
Catalog=master;User ID=HACPACK;Password=francesca"

Dim conn As New SqlConnection((connstring))

conn.Open()

Dim dataSet1 As New DataSet("NAVI")

Dim dataAdapter As New SqlDataAdapter()

dataAdapter.SelectCommand = New SqlCommand("SELECT * FROM [NAVI " + agenzia
+ " di " + porto + "] where [NOME]='" + nave + "'", conn)

dataAdapter.Fill(dataSet1, "NAVI")


Return dataSet1.Tables(0)

End Function
 
S

Steven Cheng [MSFT]

Hi DENTONE,

From your description, you're using code to programmatically bind data to a
FormView control on ASP.NET page, however, you found the FormView doesn't
populate data on the page, correct?

Based on my experience, for such databinding display issue, we can
troubleshooting via the following steps:

1. Check the FormView's aspx template to see whether the datafield/template
has been set correctly(match the data column/fields from datasource)

2. Since you're programmtically retrieve datasource object from codebehind
and attach it to FormView, you can print out the retrieved datasource(such
as DataTAble) and check whether it does contains rows(rather than empty).

3. Where did you put the databinding code you mentioned, in page_load event
or any other places? You need to makesure the functions did get called at
runtime.

If there is any other finding, welcome to post here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.


--------------------
From: "DENTONE" <[email protected]>
Subject: FORMVIEW CONTROL
Date: Thu, 8 May 2008 12:13:46 +0200
Hi,



I have added a formview to my asp.net page

and i have ad this code:

--------------------------------------------------------------------------- ---------------------------------------------------------------------

FormView1.DataSource = leggidatinave(Session("agenzia"), Session("nave"),
Session("porto"))

FormView1.DataBind()



Public Function leggidatinave(ByVal agenzia As String, ByVal nave As String,
ByVal porto As String) As DataTable

' Dim connstring As String = "Data Source=[server];Initial
Catalog=[master];User ID=[HACPACK];Password=[francesca]"

Dim connstring As String = "Data Source=serverhacpack;Initial
Catalog=master;User ID=HACPACK;Password=francesca"

Dim conn As New SqlConnection((connstring))

conn.Open()

Dim dataSet1 As New DataSet("NAVI")

Dim dataAdapter As New SqlDataAdapter()

dataAdapter.SelectCommand = New SqlCommand("SELECT * FROM [NAVI " + agenzia
+ " di " + porto + "] where [NOME]='" + nave + "'", conn)

dataAdapter.Fill(dataSet1, "NAVI")


Return dataSet1.Tables(0)

End Function

--------------------------------------------------------------------------- ---------------------------------------------------------------------
But i don't see the data in the formview control?!?!
 
D

DENTONE

1) How i can make the template programmtically
2) I put it into the page_load.

Steven Cheng said:
Hi DENTONE,

From your description, you're using code to programmatically bind data to
a
FormView control on ASP.NET page, however, you found the FormView doesn't
populate data on the page, correct?

Based on my experience, for such databinding display issue, we can
troubleshooting via the following steps:

1. Check the FormView's aspx template to see whether the
datafield/template
has been set correctly(match the data column/fields from datasource)

2. Since you're programmtically retrieve datasource object from codebehind
and attach it to FormView, you can print out the retrieved datasource(such
as DataTAble) and check whether it does contains rows(rather than empty).

3. Where did you put the databinding code you mentioned, in page_load
event
or any other places? You need to makesure the functions did get called at
runtime.

If there is any other finding, welcome to post here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

==================================================
This posting is provided "AS IS" with no warranties, and confers no
rights.


--------------------
From: "DENTONE" <[email protected]>
Subject: FORMVIEW CONTROL
Date: Thu, 8 May 2008 12:13:46 +0200
Hi,



I have added a formview to my asp.net page

and i have ad this code:

--------------------------------------------------------------------------- ---------------------------------------------------------------------

FormView1.DataSource = leggidatinave(Session("agenzia"), Session("nave"),
Session("porto"))

FormView1.DataBind()



Public Function leggidatinave(ByVal agenzia As String, ByVal nave As String,
ByVal porto As String) As DataTable

' Dim connstring As String = "Data Source=[server];Initial
Catalog=[master];User ID=[HACPACK];Password=[francesca]"

Dim connstring As String = "Data Source=serverhacpack;Initial
Catalog=master;User ID=HACPACK;Password=francesca"

Dim conn As New SqlConnection((connstring))

conn.Open()

Dim dataSet1 As New DataSet("NAVI")

Dim dataAdapter As New SqlDataAdapter()

dataAdapter.SelectCommand = New SqlCommand("SELECT * FROM [NAVI " + agenzia
+ " di " + porto + "] where [NOME]='" + nave + "'", conn)

dataAdapter.Fill(dataSet1, "NAVI")


Return dataSet1.Tables(0)

End Function

--------------------------------------------------------------------------- ---------------------------------------------------------------------
But i don't see the data in the formview control?!?!
 
S

Steven Cheng [MSFT]

Thanks for your quick response DENTONE,

For the new questions you mentioned:

1) How i can make the template programmtically
================
You mean you want to assign template programmtically for the FormView
control? Is there any particular requirement on this? Programmatically
assign template require much more code and will impact the performance.

to load template programmtically, you can save the template markup template
in a separate file(such as .ascx) and use page.Loadtemplate to load it.
Here are some article introduce this:

#Loading ASP.NET Templates Dynamically
http://www.dotnetheaven.com/UploadFile/mahesh/DynamicTemplate05112005005542A
M/DynamicTemplate.aspx?ArticleID=6d76b182-d79f-49a3-99d1-f063bae3a930

http://www.developerfusion.co.uk/show/4721/



2) I put it into the page_load.
===============
I think Page_Load event should be ok. Have you tried using some
Response.Write statement to printout the returned datasource (datatable)'s
row count? Also, if debugging is possible, you can set breakpoint and check
the datasource object.

Please feel free to let me know if there is anything you unclear.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
From: "DENTONE" <[email protected]>
References: <[email protected]>
Subject: Re: FORMVIEW CONTROL
Date: Fri, 9 May 2008 09:24:13 +0200
1) How i can make the template programmtically
2) I put it into the page_load.

Steven Cheng said:
Hi DENTONE,

From your description, you're using code to programmatically bind data to
a
FormView control on ASP.NET page, however, you found the FormView doesn't
populate data on the page, correct?

Based on my experience, for such databinding display issue, we can
troubleshooting via the following steps:

1. Check the FormView's aspx template to see whether the
datafield/template
has been set correctly(match the data column/fields from datasource)

2. Since you're programmtically retrieve datasource object from codebehind
and attach it to FormView, you can print out the retrieved datasource(such
as DataTAble) and check whether it does contains rows(rather than empty).

3. Where did you put the databinding code you mentioned, in page_load
event
or any other places? You need to makesure the functions did get called at
runtime.

If there is any other finding, welcome to post here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

==================================================
This posting is provided "AS IS" with no warranties, and confers no
rights.


--------------------
From: "DENTONE" <[email protected]>
Subject: FORMVIEW CONTROL
Date: Thu, 8 May 2008 12:13:46 +0200
Hi,



I have added a formview to my asp.net page

and i have ad this code:

-------------------------------------------------------------------------
--
---------------------------------------------------------------------
FormView1.DataSource = leggidatinave(Session("agenzia"), Session("nave"),
Session("porto"))

FormView1.DataBind()



Public Function leggidatinave(ByVal agenzia As String, ByVal nave As String,
ByVal porto As String) As DataTable

' Dim connstring As String = "Data Source=[server];Initial
Catalog=[master];User ID=[HACPACK];Password=[francesca]"

Dim connstring As String = "Data Source=serverhacpack;Initial
Catalog=master;User ID=HACPACK;Password=francesca"

Dim conn As New SqlConnection((connstring))

conn.Open()

Dim dataSet1 As New DataSet("NAVI")

Dim dataAdapter As New SqlDataAdapter()

dataAdapter.SelectCommand = New SqlCommand("SELECT * FROM [NAVI " + agenzia
+ " di " + porto + "] where [NOME]='" + nave + "'", conn)

dataAdapter.Fill(dataSet1, "NAVI")


Return dataSet1.Tables(0)

End Function

-------------------------------------------------------------------------
--
---------------------------------------------------------------------
But i don't see the data in the formview control?!?!
 
D

DENTONE

I have to make the tempalte programmatically because i have different table
that i have to show in the formview and i have to show different table for
fifferent user.
If the user is "smith" i have to show the table 1 i f user is "john" i have
to show table 2 and ... ....
Steven Cheng said:
Thanks for your quick response DENTONE,

For the new questions you mentioned:

1) How i can make the template programmtically
================
You mean you want to assign template programmtically for the FormView
control? Is there any particular requirement on this? Programmatically
assign template require much more code and will impact the performance.

to load template programmtically, you can save the template markup
template
in a separate file(such as .ascx) and use page.Loadtemplate to load it.
Here are some article introduce this:

#Loading ASP.NET Templates Dynamically
http://www.dotnetheaven.com/UploadFile/mahesh/DynamicTemplate05112005005542A
M/DynamicTemplate.aspx?ArticleID=6d76b182-d79f-49a3-99d1-f063bae3a930

http://www.developerfusion.co.uk/show/4721/



2) I put it into the page_load.
===============
I think Page_Load event should be ok. Have you tried using some
Response.Write statement to printout the returned datasource (datatable)'s
row count? Also, if debugging is possible, you can set breakpoint and
check
the datasource object.

Please feel free to let me know if there is anything you unclear.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
==================================================
This posting is provided "AS IS" with no warranties, and confers no
rights.

--------------------
From: "DENTONE" <[email protected]>
References: <[email protected]>
Subject: Re: FORMVIEW CONTROL
Date: Fri, 9 May 2008 09:24:13 +0200
1) How i can make the template programmtically
2) I put it into the page_load.

Steven Cheng said:
Hi DENTONE,

From your description, you're using code to programmatically bind data to
a
FormView control on ASP.NET page, however, you found the FormView
doesn't
populate data on the page, correct?

Based on my experience, for such databinding display issue, we can
troubleshooting via the following steps:

1. Check the FormView's aspx template to see whether the
datafield/template
has been set correctly(match the data column/fields from datasource)

2. Since you're programmtically retrieve datasource object from codebehind
and attach it to FormView, you can print out the retrieved datasource(such
as DataTAble) and check whether it does contains rows(rather than
empty).

3. Where did you put the databinding code you mentioned, in page_load
event
or any other places? You need to makesure the functions did get called
at
runtime.

If there is any other finding, welcome to post here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments
and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

==================================================
This posting is provided "AS IS" with no warranties, and confers no
rights.


--------------------
From: "DENTONE" <[email protected]>
Subject: FORMVIEW CONTROL
Date: Thu, 8 May 2008 12:13:46 +0200


Hi,



I have added a formview to my asp.net page

and i have ad this code:

------------------------------------------------------------------------- --
---------------------------------------------------------------------

FormView1.DataSource = leggidatinave(Session("agenzia"),
Session("nave"),
Session("porto"))

FormView1.DataBind()



Public Function leggidatinave(ByVal agenzia As String, ByVal nave As
String,
ByVal porto As String) As DataTable

' Dim connstring As String = "Data Source=[server];Initial
Catalog=[master];User ID=[HACPACK];Password=[francesca]"

Dim connstring As String = "Data Source=serverhacpack;Initial
Catalog=master;User ID=HACPACK;Password=francesca"

Dim conn As New SqlConnection((connstring))

conn.Open()

Dim dataSet1 As New DataSet("NAVI")

Dim dataAdapter As New SqlDataAdapter()

dataAdapter.SelectCommand = New SqlCommand("SELECT * FROM [NAVI " +
agenzia
+ " di " + porto + "] where [NOME]='" + nave + "'", conn)

dataAdapter.Fill(dataSet1, "NAVI")


Return dataSet1.Tables(0)

End Function

------------------------------------------------------------------------- --
 
S

Steven Cheng [MSFT]

Thanks for your reply DENTONE,

If the template for different users vary very much, it does need to use
separate template for them. However, I'm wondering how many users may
possibly exists in the application(each of which require its own template
of FormView)? Since so far the normal means to dynamically specify
template is loading a template from an existing file, if you have many
users, it will be not quite convenient to maintain large number of separate
template file.

If convenient, you can try pasting some of the different template for
different user here so that I can have a look at them to see whether we can
use some other means to resolve the problem.

BTW, have you resolved the original databinding data not display issue?

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.


--------------------
From: "DENTONE" <[email protected]>
Subject: Re: FORMVIEW CONTROL
Date: Fri, 9 May 2008 10:50:43 +0200
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top