Check TextBox empty condition inside GridView Row in ASP.Net

Last Reply one month ago By Azim

Posted one month ago

Below is gridview ,i wan to set condition on absent column txtabsent value should not be empty before inserting record into database 

                   <asp:GridView ID="gvv" runat="server" AutoGenerateColumns="False" BackColor="White" BorderColor="#CC9966" BorderStyle="None" BorderWidth="1px" CellPadding="4" >
                       <Columns>                                <asp:TemplateField HeaderText="ID">
                                                                  <ItemTemplate>
                                                                      <asp:Label ID="Emp_ID" runat="server" Text='<%#Bind("Emp_ID")%>'></asp:Label>
                                                                  </ItemTemplate>
                                                              </asp:TemplateField>  
                             <asp:TemplateField HeaderText="Name">
                                                                  <ItemTemplate>
                                                                      <asp:Label ID="EMp_Name" runat="server" Text='<%#Bind("EMp_Name")%>'></asp:Label>
                                                                  </ItemTemplate>
                                                              </asp:TemplateField> 
                                <asp:TemplateField HeaderText="salary">
                                                                  <ItemTemplate>
                                                                      <asp:Label ID="EMP_Salary" runat="server" Text='<%#Bind("EMP_Salary")%>'></asp:Label>
                                                                  </ItemTemplate>
                                                              </asp:TemplateField>  
                                                     <%--     <asp:TemplateField HeaderText="Allowance_Status">
                                                                  <ItemTemplate>
                                                                      <asp:Label ID="emp_allowance" runat="server" Text='<%#Bind("emp_allowance")%>'></asp:Label>
                                                                  </ItemTemplate>
                                                              </asp:TemplateField> --%>
                                <asp:TemplateField HeaderText="Loan">
                                                                  <ItemTemplate>
                                                                      <asp:Label ID="Loan" runat="server" Text='<%#Bind("Loan")%>'></asp:Label>
                                                                  </ItemTemplate>
                                                              </asp:TemplateField> 
                             <asp:TemplateField HeaderText="Advance">
                                                                  <ItemTemplate>
                                                                      <asp:Label ID="Advance" runat="server" Text='<%#Bind("Advance")%>'></asp:Label>
                                                                  </ItemTemplate>
                                                              </asp:TemplateField>  
                            <asp:TemplateField HeaderText="Mobile">
                                                                  <ItemTemplate>
                                                                      <asp:Label ID="Mobile" runat="server" Text='<%#Bind("Mobile")%>'></asp:Label>
                                                                  </ItemTemplate>
                                                              </asp:TemplateField>  
                            <asp:TemplateField HeaderText="Conveyance">
                                                                  <ItemTemplate>
                                                                      <asp:Label ID="Conveyance" runat="server" Text='<%#Bind("Conveyance")%>'></asp:Label>
                                                                  </ItemTemplate>
                                                              </asp:TemplateField>  
                            <asp:TemplateField HeaderText="Medical">
                                                                  <ItemTemplate>
                                                                      <asp:Label ID="Medical" runat="server" Text='<%#Bind("Medical")%>'></asp:Label>
                                                                  </ItemTemplate>
                                                              </asp:TemplateField>  
                            <asp:TemplateField HeaderText="Food">
                                                                  <ItemTemplate>
                                                                      <asp:Label ID="Food" runat="server" Text='<%#Bind("Food")%>'></asp:Label>
                                                                  </ItemTemplate>
                                                              </asp:TemplateField>  
                             <asp:TemplateField HeaderText="Other">
                                                                  <ItemTemplate>
                                                                      <asp:Label ID="other" runat="server" Text='<%#Bind("other")%>'></asp:Label>
                                                                  </ItemTemplate>
                                                              </asp:TemplateField>  
                             <asp:TemplateField HeaderText="OT_Hours" Visible="false">
                                                                  <ItemTemplate>
                                                                      <asp:Label ID="emp_OT" runat="server" Text='<%#Bind("emp_OT")%>'></asp:Label>
                                                                  </ItemTemplate>
                                                              </asp:TemplateField>  
                               
                                <asp:TemplateField HeaderText="Hours" Visible="false">
                                                                  <ItemTemplate>
                                                                      <asp:Textbox ID="txthour" runat="server" Text='0'  ></asp:Textbox>
                                                                  </ItemTemplate>
                                                              </asp:TemplateField> 
                                   <asp:TemplateField HeaderText="OT_Amount" Visible="false">
                                                                  <ItemTemplate>
                                                                      <asp:Label ID="lbOT_Amount" runat="server" Text='<%#Bind("lbOT_Amount")%>'></asp:Label>
                                                                  </ItemTemplate>
                                                              </asp:TemplateField> 
                              
                                  <asp:TemplateField HeaderText="Present">
                                                                  <ItemTemplate>
                                                                      <asp:label ID="txtpresent" runat="server" Text='0' ></asp:label>
                                                                  </ItemTemplate>
                                                              </asp:TemplateField> 
                                 <asp:TemplateField HeaderText="Absent">
                                                                  <ItemTemplate>
                                                                      <asp:TextBox ID="txtabsent" runat="server"  AutoPostBack="true" OnTextChanged="OnCalculate"></asp:TextBox>
                                                                  </ItemTemplate>
                                                              </asp:TemplateField> 
                                              <asp:TemplateField HeaderText="Salary">
                                                                  <ItemTemplate>
                                                                      <asp:label ID="txtsalary"  runat="server" Text='0'></asp:label>
                                                                  </ItemTemplate>
                                                              </asp:TemplateField> 
                            </Columns>
                            <FooterStyle BackColor="#FFFFCC" ForeColor="#330099" />
                            <HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="#FFFFCC" />
                            <PagerStyle BackColor="#FFFFCC" ForeColor="#330099" HorizontalAlign="Center" />
                            <RowStyle BackColor="White" ForeColor="#330099" />
                            <SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="#663399" />
                            <SortedAscendingCellStyle BackColor="#FEFCEB" />
                            <SortedAscendingHeaderStyle BackColor="#AF0101" />
                            <SortedDescendingCellStyle BackColor="#F6F0C0" />
                            <SortedDescendingHeaderStyle BackColor="#7E0000" />
                        </asp:GridView>

 

Posted one month ago Modified on one month ago