Sie Ste

Sie Ste

  • NA
  • 196
  • 183.8k

obtain data for asp.net web forms

Nov 4 2011 8:53 PM
I am wrting a few new web forms in C#asp.net 2010 and I am working with a formview and detailview controls. I have changed some columns to template fields and now I am working with them. What I would like to know if I can take a session variable and/or a local variable and place it in the location in the item template where the database column is obtained from?

The following is an example:

<asp:TemplateField HeaderText="Organization Name" >
<ItemTemplate>
<asp:TextBox ID="TextBoxOrgName" runat="server" Text='<%# eVAL(Session["CompanyName") %>'>' ></asp:TextBox>

</ItemTemplate>
</asp:TemplateField>



Basically is there a way to replace '<%# eVAL(Session["CompanyName") %>'>' with a value that would have been obtained from the database? If so, how would you code this? if not, what is your suggestion besides forcing a database column to have this data just to show the value on a web form page?

Answers (2)