how to hightlight a value from the dropdown list using gridview....
-
Hi All, I need one help regarding gridview, I placed a dropdownlist inside the gridview for a perticular column let us assume that dropdownlist contains items like Pass,Fail and NA. from the Database i will get any value(Pass/Fail/NA), now based on this value i want to highlight the dropdown list with corresponding value. can anybody guid me, how to implement this. i am doing this asp.net with c#.
-
Hi All, I need one help regarding gridview, I placed a dropdownlist inside the gridview for a perticular column let us assume that dropdownlist contains items like Pass,Fail and NA. from the Database i will get any value(Pass/Fail/NA), now based on this value i want to highlight the dropdown list with corresponding value. can anybody guid me, how to implement this. i am doing this asp.net with c#.
Hi Dayakar, There is an event of gridview called on RowDataBound. In that event you have to bind the dropdown text with the value i.e. coming from database. suppose your dropdownlist name is ddlResult and gridview gvResultSheet gvResultSheet_RowDataBound( object sender, GridVieRowEventArg e) { DropDownList ddlResult; if (e.Row.RowType == DataControlRowType.DataRow) { ddlResult = (DropDownList) e.findcontrol("ddlResult"); if(ddlResult != null && ddlResult.Items.Count > ) { ddlResult.SelectedValue = yourdatasource value; } } } add proper code for yourdatasourcevalue. And let me know if you have some trouble.
-
Hi Dayakar, There is an event of gridview called on RowDataBound. In that event you have to bind the dropdown text with the value i.e. coming from database. suppose your dropdownlist name is ddlResult and gridview gvResultSheet gvResultSheet_RowDataBound( object sender, GridVieRowEventArg e) { DropDownList ddlResult; if (e.Row.RowType == DataControlRowType.DataRow) { ddlResult = (DropDownList) e.findcontrol("ddlResult"); if(ddlResult != null && ddlResult.Items.Count > ) { ddlResult.SelectedValue = yourdatasource value; } } } add proper code for yourdatasourcevalue. And let me know if you have some trouble.
gvResultSheet_RowDataBound( object sender, GridVieRowEventArg e) { DropDownList ddlResult; if (e.Row.RowType == DataControlRowType.DataRow) { ddlResult = (DropDownList) e.findcontrol("ddlResult"); if(ddlResult != null && ddlResult.Items.Count > ) { ddlResultItems.FindByText(yourdatasource value).Selected = true; } } } try this.
-
gvResultSheet_RowDataBound( object sender, GridVieRowEventArg e) { DropDownList ddlResult; if (e.Row.RowType == DataControlRowType.DataRow) { ddlResult = (DropDownList) e.findcontrol("ddlResult"); if(ddlResult != null && ddlResult.Items.Count > ) { ddlResultItems.FindByText(yourdatasource value).Selected = true; } } } try this.