Passing sql values from code in-front to code-behind

Looking for syntax help.

I have a method that get's called by a dropdownlist in the EditItemTemplate of a DataGrid:

protected DataTable NearbyEmployees(string store,string chain,string city,string state)

{

DataTable dt = DAL.Employee.AvailableEmployees(store,chain,city,state);

return dt;

}

I need to set the DataSource of the DropDownList, for example if hardcoded, could be:
DataSource='<%#(NearbyEmployees("0100","222","Minnetonka","MN"))%>'

This works fine, now,
I need to pass parameters using DataBinder.Eval(Container.DataItem, "values") so tried something like:
DataSource='<%#(NearbyEmployees(DataBinder.Eval(Container.DataItem,"store",etc. but getting error that has invalid values.

Any help is greatly appreciated.


 

0
steveba
8/9/2005 8:01:03 PM
asp.net.presentation-controls 72751 articles. 3 followers. Follow

5 Replies
641 Views

Similar Articles

[PageSpeed] 39

Try:

<asp:dropdownlist ... datasource='<%#NearbyEmployees(Container.DataItem("store"), Container.DataItem("chain"), Container.DataItem("city"), Container.DataItem("state"))%>'
Sonu Kapoor [MVP]
Feel free to ask me any .NET question | Ajax Data Controls Forum
0
SonuKapoor
8/9/2005 8:19:47 PM
Thanks for the response. This gives me the following error:

CS0118: 'System.Web.UI.WebControls.DataGridItem.DataItem' denotes a 'property' where a 'method' was expected
0
steveba
8/10/2005 12:07:39 PM
I am a VB guy, thats why it didnt worked for you. Replace Container.DataItem("x") with Container.DataItem["x"]
Sonu Kapoor [MVP]
Feel free to ask me any .NET question | Ajax Data Controls Forum
0
SonuKapoor
8/10/2005 1:13:02 PM
This produces the following error:

CS0021: Cannot apply indexing with [] to an expression of type 'object'
0
steveba
8/10/2005 3:16:33 PM
hm..I have used Container.DataItem("col") a lot in my pages and it worked, but I am also using VB.NET. I am not sure about that in C#. I think its just a syntax problem. See if this articles helps at all.
Sonu Kapoor [MVP]
Feel free to ask me any .NET question | Ajax Data Controls Forum
0
SonuKapoor
8/10/2005 8:31:45 PM
Reply: