Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login




Remember Me
Forgot Password?
Join Us!

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.
Jobs from Indeed

Link To This Forum!

Partner Button
Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

kmfna (MIS) (OP)
4 Oct 04 12:58
Hello all,

I was curious if anyone knows if there are any events, like the lost focus of text boxes, for individual cells in a datagrid.  I have a couple of functions that I call on the lost focus for any text boxes that have to be currency...which includes some validation.  I really need to call this for a datagrid that users will be entering new data into (or possibly editing data).  I would guess that there is something similar, since the grid dynamically creates new rows after you tab out of the last column.  Any ideas on how to reference this?

Thanks in advance,
Kevin

- "The truth hurts, maybe not as much as jumping on a bicycle with no seat, but it hurts."

meydz (Programmer)
5 Oct 04 2:32
Hi!
You can use template column to insert ASP.NET validators so that the validation happens on the client side. Below is sample snippet.

<asp:datagrid id="productGrid" Width="100%" AutoGenerateColumns="False" Runat="server">
   <Columns>
     <asp:TemplateColumn HeaderText="Product">            <ItemTemplate>                             <asp:Label id=productLabel runat="server" Width="100%" Text='<%# DataBinder.Eval(Container, "DataItem.Product") %>'>                     </asp:Label>                    </ItemTemplate>                        <EditItemTemplate>                         <asp:TextBox id=productTextBox style="TEXT-ALIGN: center" runat="server" Width="100%" Text='<%# DataBinder.Eval(Container, "DataItem.Product") %>' MaxLength="4">                                   </asp:TextBox>                        <asp:CompareValidator id="Comparevalidator2" runat="server" ErrorMessage="Product unit is not a valid number."
 ControlToValidate="productTextBox" Display="None" Operator="DataTypeCheck" Type="Integer"></asp:CompareValidator>                    <asp:RequiredFieldValidator id="Requiredfieldvalidator2" runat="server" ErrorMessage="Please enter the Product unit."
 ControlToValidate="productTextBox" Display="None"></asp:RequiredFieldValidator>            </EditItemTemplate>    
    </asp:TemplateColumn>
</Columns>
</asp:datagrid>

hope this helps!

meydz
DaZZleD (Programmer)
5 Oct 04 4:23
afaik you have an event called CurrentCellChanged.

--------------------------
"two wrongs don't make a right, but three lefts do" - the unknown sage

kmfna (MIS) (OP)
8 Oct 04 15:44
ooo.....thanks guys....sorry I didn't thank you earlier, I just got back from being out of town.

I'll check out these options.

Thanks again,

Kevin

- "The truth hurts, maybe not as much as jumping on a bicycle with no seat, but it hurts."

kmfna (MIS) (OP)
20 Oct 04 14:16
Ok, I have tried doing the currentcellchanged event in our datagrid, but ended up getting stuck in an infinite loop (somewhat embarassing since I haven't done that in years).  In the currentcellchanged I used the column and row to establish if I wanted to call the validation code that I have written.  Is there any better way to handle it, than forcing a check for the column and row every time a user tabs through the grid?  Like, can I force it to call my validation code only when the user leaves a certain cell?

Any help would be appreciated.

thanks in advance,
Kevin

- "The truth hurts, maybe not as much as jumping on a bicycle with no seat, but it hurts."

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close