DENTONE
Fri May 09 03:50:43 CDT 2008
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/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:
> msdnmg@microsoft.com.
>
> ==================================================
> 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" <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.aspx#notif
>>> 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?!?!
>>>>
>>>>
>>>>
>>>>
>>>>
>>>
>>
>>
>>
>