First of all I must say that I am a newbie when it comes to net language.
This is my problem.
I want to show `HyperLink3` enabled when the Bind("myState") is equal to `validate` and show `HyperLink3` desabled when the Bind("myState") is equal to `not validate`.
If you have link for similar task, please give it me.
Can you help me? thank you in advance.
Your help would be very appreciated
Thanks for your time and hints
DataTextField="myState"
DataValueField="myState"
SelectedValue='<%# Bind("myState") %>'
Font-Size="8pt"/>
Chevy Mark SunderlandPosted Apr 10, 2012, 7:28 AM
what is your suggestion?
SenthilkumarPosted Apr 10, 2012, 7:07 AM
You are right! I misunderstood the use case.
That will find the rows while binding. That time it will not have the selected value in the drop down list.
You need to write the event for while selecting in the drop down list. Enable the auto post back property.
See this thread having solution.
http://forums.asp.net/t/1511012.aspx/1?Event+handler+of+Dropdownlist+inside+Gridview
you need to change the logic slightly.
Chevy Mark SunderlandPosted Apr 10, 2012, 6:16 AM
I'd appreciate your help so very much.
Unfortunately your suggestion does not work the NavigateUrl='<%# Eval("Link") %>' is always enable when `myState` is `validate` or not.
Thanks for your time and hints.
protected void gvCustomers_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
HyperLink HyperLink3 = (HyperLink)e.Row.FindControl("HyperLink3");
DropDownList ddlState = (DropDownList)e.Row.FindControl("myState");
if (ddlState.SelectedIndex >= 0)
{
if (ddlState.SelectedItem.Value == "validate")
{
HyperLink3.Enabled = true;
}
else if (ddlState.SelectedItem.Value == "not validate")
{
HyperLink3.Enabled = false;
}
}
}
}
DataTextField="myState"
DataValueField="myState"
SelectedValue='<%# Bind("myState") %>'
Font-Size="8pt"/>
SenthilkumarPosted Apr 10, 2012, 6:03 AM
You need to write the onrowdatabound event to the grid.