[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

DENTONE

5/8/2008 10:14:00 AM

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?!?!




5 Answers

stcheng

5/9/2008 3:14:00 AM

0

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:
msdnmg@microsoft.com.

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

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


--------------------
>From: "DENTONE" <dinodentone@community.nospam>
>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?!?!
>
>
>
>
>

DENTONE

5/9/2008 7:24:00 AM

0

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

"Steven Cheng [MSFT]" <stcheng@online.microsoft.com> ha scritto nel
messaggio news:zmsJJLYsIHA.4284@TK2MSFTNGHUB02.phx.gbl...
> 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:
> msdnmg@microsoft.com.
>
> ==================================================
> Get notification to my posts through email? Please refer to
> http://msdn.microsoft.com/subscriptions/managednewsgroups/default....
> ications.
>
> ==================================================
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
>
>
> --------------------
>>From: "DENTONE" <dinodentone@community.nospam>
>>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?!?!
>>
>>
>>
>>
>>
>


stcheng

5/9/2008 8:32:00 AM

0

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/DynamicTemplate05112...
M/DynamicTemplate.aspx?ArticleID=6d76b182-d79f-49a3-99d1-f063bae3a930

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



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:
msdnmg@microsoft.com.

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

--------------------
>From: "DENTONE" <dinodentone@community.nospam>
>References: <uqFY$QPsIHA.1436@TK2MSFTNGP05.phx.gbl>
<zmsJJLYsIHA.4284@TK2MSFTNGHUB02.phx.gbl>
>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 [MSFT]" <stcheng@online.microsoft.com> ha scritto nel
>messaggio news:zmsJJLYsIHA.4284@TK2MSFTNGHUB02.phx.gbl...
>> 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:
>> msdnmg@microsoft.com.
>>
>> ==================================================
>> Get notification to my posts through email? Please refer to
>>
http://msdn.microsoft.com/subscriptions/managednewsgroups/default....
>> ications.
>>
>> ==================================================
>> This posting is provided "AS IS" with no warranties, and confers no
>> rights.
>>
>>
>> --------------------
>>>From: "DENTONE" <dinodentone@community.nospam>
>>>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?!?!
>>>
>>>
>>>
>>>
>>>
>>
>
>
>

DENTONE

5/9/2008 8:51:00 AM

0

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 [MSFT]" <stcheng@online.microsoft.com> ha scritto nel
messaggio news:75WPh8asIHA.1788@TK2MSFTNGHUB02.phx.gbl...
> 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/DynamicTemplate05112...
> M/DynamicTemplate.aspx?ArticleID=6d76b182-d79f-49a3-99d1-f063bae3a930
>
> http://www.developerfusion.co.uk/...
>
>
>
> 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:
> msdnmg@microsoft.com.
>
> ==================================================
> Get notification to my posts through email? Please refer to
> http://msdn.microsoft.com/subscriptions/managednewsgroups/default....
> ications.
> ==================================================
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
>
> --------------------
>>From: "DENTONE" <dinodentone@community.nospam>
>>References: <uqFY$QPsIHA.1436@TK2MSFTNGP05.phx.gbl>
> <zmsJJLYsIHA.4284@TK2MSFTNGHUB02.phx.gbl>
>>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 [MSFT]" <stcheng@online.microsoft.com> ha scritto nel
>>messaggio news:zmsJJLYsIHA.4284@TK2MSFTNGHUB02.phx.gbl...
>>> 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:
>>> msdnmg@microsoft.com.
>>>
>>> ==================================================
>>> Get notification to my posts through email? Please refer to
>>>
> http://msdn.microsoft.com/subscriptions/managednewsgroups/default....
>>> ications.
>>>
>>> ==================================================
>>> This posting is provided "AS IS" with no warranties, and confers no
>>> rights.
>>>
>>>
>>> --------------------
>>>>From: "DENTONE" <dinodentone@community.nospam>
>>>>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?!?!
>>>>
>>>>
>>>>
>>>>
>>>>
>>>
>>
>>
>>
>


stcheng

5/12/2008 3:02:00 AM

0

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:
msdnmg@microsoft.com.

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


--------------------
>From: "DENTONE" <dinodentone@community.nospam>
>Subject: Re: FORMVIEW CONTROL
>Date: Fri, 9 May 2008 10:50:43 +0200

>
>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 [MSFT]" <stcheng@online.microsoft.com> ha scritto nel
>messaggio news:75WPh8asIHA.1788@TK2MSFTNGHUB02.phx.gbl...
>> 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/DynamicTemplate05112...
>> M/DynamicTemplate.aspx?ArticleID=6d76b182-d79f-49a3-99d1-f063bae3a930
>>
>> http://www.developerfusion.co.uk/...
>>
>>
>>
>> 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:
>> msdnmg@microsoft.com.
>>
>> ==================================================
>> Get notification to my posts through email? Please refer to
>>
http://msdn.microsoft.com/subscriptions/managednewsgroups/default....
>> ications.
>> ==================================================
>> This posting is provided "AS IS" with no warranties, and confers no
>> rights.
>>