Wednesday, January 25, 2012

Grid view Row Updation using Onblur event of TextBox in Javascript

Note:if you want Update gridview row when you changing the text in the textbox and you click on the out gridview or on the grideview
you can written Onblur event of textbox.
Ex:I update Quantity in the textbox by click on the webpage or gridview.
I written Onblur() event in the textbox as follows.this will call server side code

function changeQuantity(obj) {
if (obj.value == 0)
obj.value = 1;
document.getElementById('<%= ButtonName.ClientID %>').click();

server side Code:
protected void btnCheck_OnClick(object sender, EventArgs e)
{
foreach (GridViewRow item in GVCart.Rows)
{
string lPid = Convert.ToString(GVCart.DataKeys[item.RowIndex].Values["pid"]);
TextBox lQty = (TextBox)item.FindControl("txtQty");
}

}

TextBox event Onblur Is:
onblur="changeQuantity(this)"

No comments:

Post a Comment