Validations in gridview
-
:) i want to validate a databound column and a template column in a datagridview.Databound colum i am displaying from database and in template colum i am allowing the user to enter a value.when user is entering value in template column i want to check whether the user enterd value is less than or equal to the value of databound column....How can i do this......... Can anyone can help me...give some samples also........ Anu Anu
-
:) i want to validate a databound column and a template column in a datagridview.Databound colum i am displaying from database and in template colum i am allowing the user to enter a value.when user is entering value in template column i want to check whether the user enterd value is less than or equal to the value of databound column....How can i do this......... Can anyone can help me...give some samples also........ Anu Anu
anu, In RowDataBound Event write this code
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { int dbValue = (int)e.Row.Cells[0].Text; TextBox txtbox = (TextBox)e.Row.FindControl("TextBox1"); txtbox.Attributes.Add("onblur", "validateValue('"+ dbValue +"','"+ (int)txtbox.Text +"');"); } }
add this javascript code in head sectionfunction validateValue(dbvalue, enteredValue) { if(enteredValue < dbvalue) { alert("please enter the value equal or greate of column1 "); } }
hope this will help, as per the ur requirement fire this javascript validation related event. :)regards GV Ramana
-
anu, In RowDataBound Event write this code
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { int dbValue = (int)e.Row.Cells[0].Text; TextBox txtbox = (TextBox)e.Row.FindControl("TextBox1"); txtbox.Attributes.Add("onblur", "validateValue('"+ dbValue +"','"+ (int)txtbox.Text +"');"); } }
add this javascript code in head sectionfunction validateValue(dbvalue, enteredValue) { if(enteredValue < dbvalue) { alert("please enter the value equal or greate of column1 "); } }
hope this will help, as per the ur requirement fire this javascript validation related event. :)regards GV Ramana