Tuesday, 29 October 2013

grid having button click event code behind retrive grid selected checkbox values



            string ids = string.Empty;
            ids = (from GridViewRow gvSingleSavingsBookRow in grvVendorProperties.Rows
                   let rowSelected = (CheckBox)gvSingleSavingsBookRow.FindControl("chkVendorProperties")
                   let myId = (HiddenField)gvSingleSavingsBookRow.FindControl("HiddenEntityID")
                   where (null != rowSelected) && (null != myId)
                         && rowSelected.Checked
                   select myId).Aggregate(ids, (current, myId) =>
                                string.Format("{0}{1}{2}", current, myId.Value.Trim(), ","));



-----------------------------------------------------------------------------

for (int rowIndex = 0; rowIndex < grvVendorProperties.Rows.Count; rowIndex++)
            {
                TextBox txtExpenseAccount = (TextBox)grvVendorProperties.Rows[rowIndex].FindControl("txtExpenseAccount");
                TextBox txtInitialBalance = (TextBox)grvVendorProperties.Rows[rowIndex].FindControl("txtInitialBalance");
                Button btnExpenseAccount = (Button)grvVendorProperties.Rows[rowIndex].FindControl("btnExpenseAccount");
                TextBox txtEffectiveDate = (TextBox)grvVendorProperties.Rows[rowIndex].FindControl("txtEffectiveDate");
                TextBox txtReceiptAccount = (TextBox)grvVendorProperties.Rows[rowIndex].FindControl("txtReceiptAccount");
                Button btnReceiptAccount = (Button)grvVendorProperties.Rows[rowIndex].FindControl("btnReceiptAccount");

                CheckBox chk = (CheckBox)grvVendorProperties.Rows[rowIndex].FindControl("chkVendorProperties");

                if (chk.Checked == true)
                {
                    chk.Checked = true;
                    txtExpenseAccount.Enabled = true;
                    txtInitialBalance.Enabled = true;
                    btnExpenseAccount.Enabled = true;
                    txtEffectiveDate.Enabled = true;
                    txtReceiptAccount.Enabled = true;
                    btnReceiptAccount.Enabled = true;
                }
                else
                    chk.Checked = false;
            }

No comments:

Post a Comment