Click here to Skip to main content
15,887,214 members

Comments by Upadhyay Praveen (Top 11 by date)

Upadhyay Praveen 29-Jan-15 15:12pm View    
My requirement is :- I have a gridview, where based on dropdown value i need to disable/enable the next control that is textBox.
I tried below code.

<script language = "javascript" type = "text/javascript">

function disableQuizID(txtNewQuizID, ddlNewCategory) {

if (ddlNewCategory.value == "4") {
alert("Testing1"); //Testing purpose.
document.getElementById(txtNewQuizID).disabled = true;
alert("Testing2");

}
else {
document.getElementById(txtNewQuizID).disabled = false;
}
}
</script >

while creating GridView in aspx page, I have given OnRowCreated="grdQuestions_RowCreated"

Now aspx.cs

protected void grdQuestions_RowCreated(Object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Footer)
{
DropDownList ddlNewCategory = (DropDownList)e.Row.FindControl("ddlNewCategory");
TextBox txtNewQuizID = (TextBox)e.Row.FindControl("txtNewQuizID");

ddlNewCategory.Attributes.Add("onchange", "disableQuizID('" + txtNewQuizID.ClientID + "', this);");

}
}

The dropdown has 4 values, If the selected value is 4 then the Textbox should be disabled/readonly. I tested above code, when i select value 4 in dropdown, the alert("testing1") comes, but alert("testing2") dont come. Please help. I am trying to find out from long time, did not get the solution. Please let me know if you want more info.
Upadhyay Praveen 18-Jan-15 3:22am View    
Thanks, But 3rd column i can not add. This table has huge record.
Upadhyay Praveen 17-Jan-15 16:16pm View    
Its coming into two column. I am expecting 5 columns.

35 Apple Ball Cat Dog
36 Cricket Football Hockey null

**Each word i want in separate column. but, except 35,36 rest all are in one column.
Upadhyay Praveen 5-Dec-14 12:30pm View    
Thanks.
Upadhyay Praveen 5-Dec-14 12:29pm View    
Thanks.