How to set Eval("DropDownList.SelectedItem.text") programmatically to gridview in asp.net c# -


aspx.cs file is: design

cs file code:

enter image description here marks database structure marks(standard varchar(20),type_of_exam varchar(20),telugu varchar(20),hindi varchar(20),eng......)

i give subjects in dropdown list items telugu,hindi,english,.....

i use gridview show subject marks.my question is.

i give gridview header name "subject" ; how give "eval" function subject. has show telugu marks when select telugu item in dropdownlist , show hindi marks when select hindi marks.

thanks in advance spending time read question. how can dynamically bind gridview based on values drop drop down list?.

in .aspx

'<%# dropdownlist2.selecteditem.text %>'

without eval or doublequotes. exposing server-side control property , don't need use eval not evaluating expression bound data-item.

you can use rowcreated event or rowdatabound gridview :

protected void mygrid_rowcreated(object sender, gridviewroweventargs e) {     //dowhatever need     textbox t = e.row.cells[4].findcontrol("subject") textbox;     t.text = dropdownlist2.selecteditem.text;    } 

Comments