1

aspx.cs file is: design

CS file code:

enter image description here My marks database structure is marks(Standard varchar(20),Type_of_Exam varchar(20),telugu varchar(20),hindi varchar(20),eng......)

I give those subjects in dropdown list items like telugu,hindi,english,.....

I use gridview to show that subject marks.My Question is.

I give gridview header name "subject" ; How to give "eval" function to that subject. That has to show telugu marks when i am select telugu item in dropdownlist and show hindi marks when i am select hindi marks.

Thanks in Advance for spending time to read my question. How can i dynamically bind gridview based on the values from the drop drop down list?.

Ajay
  • 2,022
  • 19
  • 33

1 Answers1

0

In .aspx

'<%# DropDownList2.SelectedItem.Text %>'

WITHOUT the Eval Or DoubleQuotes. you are just exposing server-side control property and you don't need to use Eval as you are not evaluating an expression from a bound Data-item.

You can also use the RowCreated event or RowDataBound for your gridview :

protected void MyGrid_RowCreated(object sender, GridViewRowEventArgs e)
{
    //DoWhatever you Need
    TextBox t = e.Row.Cells[4].FindControl("subject") as TextBox;
    t.Text = DropDownList2.SelectedItem.Text;   
}
sm_
  • 2,572
  • 2
  • 17
  • 34