How to use the new "Bind()" ?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,
I am trying to use the new "Bind" instead of "DataBinder.Eval" but cannot
see a way to use it in code. Can someone help?. Here is my code that is using
"DataBinder.Eval" which I want to change to "Bind" method.

Sub BindStringColumn(ByVal sender As Object, ByVal e As EventArgs)
Dim lbl2 As Label = CType(sender, Label)
Dim Container As DataGridItem = CType(lbl2.NamingContainer,
DataGridItem)
lbl2.Text = DataBinder.Eval(Container.DataItem, Field2)
End Sub

Thanks,
Ganesh
 
Bind should be used declaritively as bellow

<asp:TextBox ID="ProductNameTextBox" runat="server" Text='<%#
Bind("ProductName") %>'>

Note the text property of the textbox

You can also return to you local MSDN for databinding expressions on
ms-help://MS.MSDNQTR.v80.en/MS.MSDN.v80/MS.VisualStudio.v80.en/dv_aspnetcon/html/14cdd57d-0f82-4667-b503-73e1a96f136a.htm

or on msdn website on:
http://msdn2.microsoft.com/en-us/library/ms178366.aspx

Reagrds
 
Yes, I see that but how would I use that syntax in a ItemTemplate..
Basically, the syntax you have given will work in the aspx page but how would
I use the same in codebehind?.

Thanks for your help!
Ganesh
 
I don't think you can use it the same way, specially that Bind is not member
of DataBinder Class

--
Muhammad Mosa
Software Engineer & Solution Developer
MCT/MCSD.NET
MCTS: .Net 2.0 Web Applications
MCTS: .Net 2.0 Windows Applications
 
Back
Top