Tuesday, June 29, 2010

How to Identify a changed row from a dropdownlist in a datagrid iew

protected void ddlPramotionType_SelectedIndexChanged(object sender, EventArgs e)
{
DropDownList test = (DropDownList)sender;


foreach (GridViewRow row in gvInvoiceItemList.Rows)
{
if (row.RowType ==DataControlRowType.DataRow)
{

DropDownList ddlPramotionType = (DropDownList)row.FindControl("ddlPramotionType");

if (test.ClientID == ddlPramotionType.ClientID)
{
TextBox txtNoOfPacks = ((TextBox)row.FindControl("txtNoOfPacks"));
TextBox txtDiscount = ((TextBox)row.FindControl("txtDiscount"));

if (ddlPramotionType.SelectedItem.Value == "Discount")
{
txtNoOfPacks.Enabled = false;
txtDiscount.Enabled = true;
}
else if (ddlPramotionType.SelectedItem.Value == "FreePack")
{
txtNoOfPacks.Enabled = true;
txtDiscount.Enabled = false;
}
else
{
txtNoOfPacks.Enabled = false;
txtDiscount.Enabled = false;
}
}
}

}
}

No comments:

Post a Comment