Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Session in databinding....

Status
Not open for further replies.

bobetko

Programmer
Jan 14, 2003
155
US
How can I include session variable in databinding.
Example:
Code:
<asp:ImageButton ID="btnPreview" runat="server"  OnCommand="ImagePreview_Command" CommandArgument='<%# Session["UserFolder"] + "images/" + Eval("filename") %>'/>

I would like commandArgument of above image button to be something like:
Session["UserFolder"] + "images/" + Eval("filename")

How to do this properly?

Thanks
 
should I rewrite the question? This one should be easy!?
 
Write a function to return the string with the value of your session variable

Your asp:ImageButton attribute:
Code:
CommandArgument='<%# GetUserFolder(filename) %>'

Your .Net code
Code:
protected void GetUserFolder(string strFileName)
{
   return Convert.ToString(Session["UserFolder"]) + "images/" + strFileName;

}

hth


}
 
Oops the function call should be

Code:
CommandArguement='<%# GetUserFolder(Convert.ToString(Eval("filename"))) %>'
 
GetUserFolder function is returning a value, so protect string... instead of protect void ....

Works great, thank you. I didn't have idea what to google to look for this answer.

Thanks.
 
sorry for the typos, at least you caught that. teaches me to answer while I'm talking on the phone :p . Glad I could help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top