Click here to Skip to main content
15,892,737 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Actually if i entered data in text-box means check box should be checked....... and below is my code...

XML
<asp:GridView ID="GridView1" ShowHeader="False" runat="server" Width="95%"
                AutoGenerateColumns="False" DataSourceID="SqlDataSource1"
                DataKeyNames="DxID" ondatabound="GridView1_DataBound"
            onrowcreated="GridView1_RowCreated" onrowdatabound="GridView1_RowDataBound"
            onselectedindexchanged="GridView1_SelectedIndexChanged" CellSpacing="5"
            CssClass="grid" onrowcommand="GridView1_RowCommand"  >
                    <AlternatingRowStyle CssClass="alternatingItemStyle" />
                    <HeaderStyle CssClass="Headerstyle" />
                    <RowStyle  CssClass="RowStyle"/>
                    <SelectedRowStyle CssClass="SelectedRowStyle" />
                <Columns>
                    <asp:TemplateField>
                        <ItemTemplate>
                                       <span class="style3"><asp:CheckBox ID="chkSelect" runat="server" Checked= '<%# GetValue(Eval("IsCheck").ToString()) %>'  /></span>

                                    <asp:TextBox ID="TextBox2" runat="server" Width="95%" Height="85px"
                                        TextMode="MultiLine" CssClass="inpt_a" Font-Names="Open Sans , sans-serif"   onkeypress="check(this)"   Text='<%# Bind("Plan4") %>'></asp:TextBox>
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
                <HeaderStyle Height="0px" />
            </asp:GridView>
Posted
Updated 23-Feb-14 16:54pm
v3

1 solution

Try onkeyup event like this:
XML
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script  type="text/javascript">
    function check() {
            // remove leading and trailing spacing
        var textboxcontent = document.getElementById("<%=TextBox1.ClientID%>").value.trim();
            document.getElementById("<%=CheckBox1.ClientID%>").checked = (textboxcontent.length > 0);
        }
</script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:CheckBox ID="CheckBox1" runat="server" />
    </div>
    <p>
        <asp:TextBox ID="TextBox1" runat="server" onkeyup="check()"></asp:TextBox>
    </p>
    </form>
</body>
</html>
 
Share this answer
 
v4
Comments
ntitish 23-Feb-14 22:50pm    
thanks sir for your post.........here i need in onkeypress event of a textbox. and that to in grid view......i update my question with gridview. can you please see that....
Peter Leow 24-Feb-14 0:13am    
Check out my solution to one of the similar question here
ntitish 24-Feb-14 0:44am    
Sir in your link you explained for validation but here i need to check the check box. may be you are right but i am unable to find the logic.....but this is urgent functionality to fix it to me so may be because of that i am not getting your intention.
praks_1 24-Feb-14 0:36am    
To get the textbox event 1)find grid control and then use the control event.
ntitish 24-Feb-14 0:53am    
Sir i will find the grid control but how to check the check box of the particular text box which i entered data...that is the problem.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900