Pages

Thursday, 5 July 2012

How to Update product in multiple categories insert and update in one time


foreach (DataListItem item in DataList1.Items)
        {
            // Get the checkbox control that contain the user selection.
            CheckBox cbSelProducts = (CheckBox)item.FindControl("cbSelProduct");
            if (cbSelProducts != null && cbSelProducts.Checked)
            {
                // Label lblProductName = (Label)row.FindControl("lblProductName");
                /// Get the product id of the selected product

                string TitleId = "";
                Label id = (Label)item.FindControl("lblCatId");
                for (int j = 0; j < ds.Tables[0].Rows.Count; j++)
                {
                    if (id.Text == ds.Tables[0].Rows[j]["CategoriesId"].ToString())
                    {
                        k = 1;
                        break;
                    }
                    else
                    {
                        k = 0;
                    }
                }
                if (k == 1)
                {
update query write here
}
else

{
insert query
}

}

No comments:

Post a Comment