예제 #1
0
        public void dgCommand_onClick(System.Object o, System.Web.UI.WebControls.DataGridCommandEventArgs e)
        {
            string strCommandName;
            int    intId, intItemId;



            strCommandName = e.CommandName;
            intId          = e.Item.ItemIndex;

            //delete an item
            if (strCommandName == "cmdDelete")
            {
                intItemId = (int)dbgrid.DataKeys[intId];

                payloadDataAccess.delete(intItemId);
                dbGrid_bind();
            }

            if (strCommandName == "cmdUpdate")
            {
                intItemId = (int)dbgrid.DataKeys[intId];

                lblHiddenId.Text = intItemId.ToString();

                objPayload.id = intItemId;
                objPayload.populate();

                txtPayloadName.Text  = "" + objPayload.payloadName;
                txtPayloadData.Text  = "" + objPayload.payloadData;
                txtDescription.Text  = "" + objPayload.description;
                txtPayloadOrder.Text = "" + objPayload.payloadOrder;



                dropDownType.ClearSelection();

                foreach (ListItem objListItem in dropDownType.Items)
                {
                    if (objListItem.Value == objPayload.type.ToString())
                    {
                        objListItem.Selected = true;
                        break;
                    }
                }



                cmdAdd.Text = "Update";



                panelAdd.Visible = true;
            }
        }
        private void dropDownPayloads_SelectedIndexChange(object sender, System.EventArgs e)
        {
            if (dropDownPayloads.SelectedIndex == 0)
            {
                return;
            }

            payload objPayload = new payload();

            objPayload.id = System.Convert.ToInt32(dropDownPayloads.SelectedItem.Value);
            objPayload.populate();

            txtPayload.Text = "" + objPayload.payloadData;
        }