Data presentation without a data control

The Gridview and Formview controls provide good functionality in some circumstances but are clumsey in others. As a newbie to .NET I was wondering if its appropriate to do databinding with textboxes and other data controls outside of one of the new data controls (formview, gridview, etc). Or is it a new standard to always use one of the new data controls. If the answer is yes, would you still use an SQLDatasource, or would you set up the connection in code? And, how would you deal with the syntax? In the Formview we have:

<asp:TextBox ID="fnameTextBox" runat="server" Text='<%# Bind("fname") %>' />

How would you modify this to refer to the connection if it was outside of the Formview and needed to reference the SQLDatasource or connection directly?

Thanks

0
dwfreeman
6/6/2008 5:28:40 PM
asp.net.getting-started 91979 articles. 3 followers. Follow

3 Replies
901 Views

Similar Articles

[PageSpeed] 30

 You can use Table inside gridview or formview if you want. For example:

    <asp:FormView ID="FormView2" runat="server" DefaultMode="Edit" DataSourceID="ObjectDataSource1">
    <EditItemTemplate>
   
    <table  >
                    
            <tr><td ><b>Name:</b></td><td ><asp:TextBox runat="server" ID="Name" Text='<%# Bind("Name") %>' Height="18px" Width="250px"/></td></tr> 
 

<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="Your method" TypeName="something" >


_____________________________________________________________
Please remember to click "Mark as Answer" if you get the answer.

Thanks
~AK
0
mominlhp
6/6/2008 7:57:15 PM

Mominlhp -

Thanks for your reply. I was aware that you could use tables inside the Formview, but sometimes even that leaves much to be desired. I was experimenting with absolute positioning and found that to be difficult when inside the formview. Hence my question to see if we could drop the formview altogether and just use the controls without the formview.

However your response brings up another question. All the samples I have seen use SQLDatasource with the Formview. Your sample uses ObjectDataSource. Can you highlight the differences and suggest when to use one over the other?

 

0
dwfreeman
6/6/2008 8:24:30 PM

The following link might help you a little.

http://www.mikesdotnetting.com/Article.aspx?ArticleID=45 

http://geekswithblogs.net/joycsharp/archive/2006/11/15/97221.aspx

 



_____________________________________________________________
Please remember to click "Mark as Answer" if you get the answer.

Thanks
~AK
0
mominlhp
6/6/2008 9:20:44 PM
Reply: