Friday, November 27, 2015

How to enable required field validator in a particular row of GridView?

Scenario:
In some cases editing is enabled on the selected row when you doing batch editing in ASP.NET GridView or DevExpress Grid Control. During edit operation we need to validate only these selected rows editor controls so that it will not block or validated another rows. It require to enable only associated cell validators in the editing rows.
Solution:
Let we have a checkbox in each row to select the editing row to enable the validator controls. Then we have to follow below steps:
First you need to add server event on Check Box control of Change event fire.
<asp:CheckBox ID="chkbox" runat="server" OnCheckedChanged="chkbox_CheckedChanged"    AutoPostBack="true"/>


Then fire of checked event of Checkbox you need to enable/disable RequiredFieldValidator server control.

protected void chkbox_CheckedChanged(object sender, EventArgs e)
{
   CheckBox chkbox= sender as CheckBox;
   GridViewRow currentRow = chkbox.NamingContainer as GridViewRow;
   RequiredFieldValidator rfv = grdCustomer.Rows[currentRow.RowIndex]
                                      .FindControl("ValReqED") as RequiredFieldValidator;
   if (chkCustomer.Checked)
   {
      rfv .Enabled = true;
   }
}

ASPX:

<asp:GridView ID="grdView" AutoGenerateColumns="false" BorderWidth="0" OnRowCommand="grdView_RowCommand" runat="server" CssClass="table">
    <Columns>
        <asp:TemplateField HeaderText="Save It">
            <ItemTemplate>
                <asp:CheckBox ID="chkbox" runat="server" AutoPostBack="true" OnCheckedChanged="chkbox_CheckedChanged"/>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField HeaderText="Expiration Date">
            <ItemTemplate>
                <asp:TextBox ID="txtExpirationDate" style="padding:12px 5px;" placeholder="(mm/dd/yyyy)" CssClass="datepiker" runat="server"></asp:TextBox>
                <asp:RequiredFieldValidator ID="ValReqExpD" Enabled="false" Display="Dynamic" runat="server" ErrorMessage="Expiry Date cannot be Blank." ControlToValidate="txtExpirationDate"></asp:RequiredFieldValidator>
                <asp:RegularExpressionValidator Display="Dynamic" ID="ValRegExpD" runat="server" ControlToValidate="txtExpirationDate" ErrorMessage="Enter a valid Expiry Date ." ValidationExpression="([1-9]|0[1-9]|1[012])([-/.])([1-9]|0[1-9]|[12][0-9]|3[01])([-/.])(19[5-9][0-9]|20[0-4][0-9])">
                    <b>Enter a valid Renewal Date</b>
                </asp:RegularExpressionValidator><br />
                <asp:CompareValidator ID="ValCmpSD" Display="Dynamic" runat="server" ControlToCompare="txtEffectiveDate" ControlToValidate="txtExpirationDate" ErrorMessage="Expiry Date should be greater than Effective date" Operator="GreaterThan" Type="Date"></asp:CompareValidator>
            </ItemTemplate>
        </asp:TemplateField>
    </Columns>
</asp:GridView>



Friday, November 20, 2015

Healthy eye tips for IT professionals to keep their vision correct

Looking at current trend of advancements in technology, spending long hours in front of television, computers & mobile screens is becoming part of life style today. But in IT industry, we have to spend most part of our day in front of the computer screen to do our work. In all of this daily routine we forget about one of the most important parts of our body, the eyes. The ones that itch from sheer exhaustion and burn tirelessly after the end of a really long day. This can lead to eyes and vision related problems in future.

We might not feel the need to exercise your eyes because well, there aren't any immediate symptoms or signs of weak or tired eyes but if we want to guard our self from hazy spots and blurry vision in the future, then we suggest you exercise them as often as possible. And the eye workout is that you can do it at any given time of the day and all we need are a few minutes to avoid future problem with that part which required to do job for the living.

Here are the few EYE care tips

Ø After every 20 to 30 minutes of work, look at a distant object and blink several times. This will help in better focusing and relaxation of eye muscles

Ø Blink frequently. People tend to reduce blink rate while working on computer. This can lead to dry eyes. Avoid staring at screens & objects for long.

Ø Exercise your eyes at frequent intervals. Eye exercise is simple. All you need to do is blink several times, then close your eyes and roll them in clockwise and anti-clockwise direction. While doing this, breathe deeply but slowly and open your eyes slowly after doing this.

Ø Rub your palms against each other till they become warm. Cover your eyes with your warm palms for a minute. You will experience soothing effect in your eyes.

Ø Splashing water on your face during breaks can keep you refreshed. This also helps in cleaning and cooling your eyes.

Ø A few minutes of walk during breaks will refresh your body and mind. It is also good for your eyes as walking increases blood supply to your eyes.

Ø Position the monitor and lights in such a manner that glare from the screen is minimum. 

Few tips are simple Yoga that help to avoid eye problems. We've put together few simple yoga exercises that that will help ease out overused muscles, reduce tension in the face and eyes and help your eyes focus.

Source - Yoga for eyes
here are few yoga exercises that that will help ease out overused muscles, reduce tension in the face and eyes and help your eyes focus.

  • Blink - Open your eyes wide and then quickly blink about 10 times. Now, close your eyes for about 20 seconds and repeat this exercise four more times. The human eye should blink about 25 times in one minute. However, many of us don't, especially when we're focusing on something on our computer or smartphone. This exercise helps your eye nourish itself, relaxes the eye muscles and prevent dry eyes.
  • Palming - If you've gone for yoga classes at any point in time you'll be familiar with this one. Rub your palms together till they feel warm. Then place them on your eyes and hold the position till your palm feels warm. Concentrate on something and relax. This exercise is another form of relaxation which is something your eyes could use, especially after a long day at work.
  • Sideways & Rotation - So now you want to stretch your eye muscles. Move your eyes slowly from side to side and then all the way around in a circle. If you find that difficult, then use your finger and move it in a circle, and let your eyes follow. Make sure your neck doesn't move and repeat both those exercises about 20 times.
  • Sarvangna Asanaor the shoulder stand - This exercise doesn't just help your eyes but your brain as well. Lie down on a mat and using your arms, life your body waist downwards in the air so that your legs are straight and toes point outwards. This pose stimulates blood circulation in brain and optic nerve. You can also lay on your back and life your legs upward, as high as you can go. This exercise increases blood circulation to the eyes, brain, ears and nose, thereby improving their functioning. This pose also helps you detoxify and maximize the performance of all the other organs.

          clip_image001

  • Bhramari Pranayama - Also known as the humble bee breath, this exercise is really calming and can drown down the unnecessary noise in your head, making you feel relaxed with just a few breaths. Sit on the floor cross-legged or however you feel comfortable. Now place your fingers over your eyes horizontally. Exhale and when you inhale make a bee like buzzing sound. Make sure you apply very little pressure on the eyeball and keep your lips sealed.

Some more helpful exercises: Yoga for Eyes: Improve Eyesight Naturally