c# - ASP.NET Gridview textbox binding to a variable at runtime -
i novice asp.net, , wondering if next possible. have application bound info source (ms access) using olddbdataaadpter, , works ok however, want able display 1 of number of table fields based on user input (from drop downwards list). thought user selects 1 of (a possible 10) languages @ runtime, , have gridview display field. if can ignore construction of database moment (it legacy issue), table has number of fields (index, name, etc..) , field 1 of 10 languages (such en-us, de, es, fr, ect..). next section works fine (the variable "lang" filled dropdown list @ runtime)
string qrystr = "select pindex, tname, component, " + lang " mytbles"; globalclass.adap = new oledbdataadapter(qrystr, con); oledbcommandbuilder bui = new oledbcommandbuilder(globalclass.adap); globalclass.dt = new datatable(); globalclass.adap.fill(globalclass.dt); gridview1.datasource = globalclass.dt; gridview1.databind();
globalclass.cs follows: public class globalclass {
public static oledbdataadapter adap; public static datatable dt; // stored image path before updating record }
the problem asp code appears require exact fieldname when bound. section of asp file :
text='<%#bind("component") %>'
this shows how "component" field bound gridview textbox. question is: possible utilize variable name in "bind" sections above? want asp code able find , resolve variable .cs code behind section. not expecting show me how, know if possible (and relevant classes should looking at..) many thanks..
why not do
string qrystr = "select pindex, tname, component, " + lang " selectedlang mytbles";
then
text='<%#bind("selectedlang") %>'
c# asp.net .net asp.net-mvc gridview
No comments:
Post a Comment