Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
help for that code...i have one textbox and one label their..
XML
<body>
    <form id="form1" runat="server">
    <div>
        Customer Detail:-
        <br />
        <br />
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <table style="width: 80%">
            <tr>
                <td>
                    DC No:-
                </td>
                <td>
                    <asp:Label ID="lblDCNO" runat="server" Text="Label"></asp:Label>
                </td>
            </tr>
            <tr>
                <td>
                    Name:-
                </td>
                <td>
                    <asp:DropDownList ID="ddlstName" runat="server">
                    </asp:DropDownList>
                </td>
            </tr>
            <tr>
                <td>
                    Date:-
                </td>
                <td>
                    <asp:TextBox ID="txtDate" runat="server"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td>
                    Chalan No:-
                </td>
                <td>
                    <asp:TextBox ID="txtChalan_No" runat="server"  ></asp:TextBox>
                    <asp:Label ID="lblMsg" runat="server" Text="Label" Visible="False"></asp:Label>
                </td>
            </tr>
        </table>
        <br />
        Order Detail:-<br />
        <table style="width: 100%">
            <tr>
                <td>
                    Sr. No:-
                </td>
                <td>
                    <asp:TextBox ID="txtSrno" runat="server"  ></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td>
                    Iteam:-
                </td>
                <td>
                    <asp:DropDownList ID="ddlstItem" runat="server">
                    </asp:DropDownList>
                </td>
            </tr>
            <tr>
                <td>
                    Qty:-
                </td>
                <td>

                            <asp:TextBox ID="txtQty" runat="server" OnTextChanged="txtQty_TextChanged"   ></asp:TextBox>
                            <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"
                                ControlToValidate="txtQty" ErrorMessage="Only Numeric Value Allow"
                                ValidationExpression="^[0-9]"></asp:RegularExpressionValidator>

                </td>
            </tr>
            <tr>
                <td>
                    Rate:-
                </td>
                <td>

                            <asp:TextBox ID="txtRate" runat="server"  OnTextChanged="txtRate_TextChanged" AutoPostBack="true">
                            </asp:TextBox>
                            <asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server"
                                ControlToValidate="txtRate" ErrorMessage="Only Numeric Value Allow"
                                ValidationExpression="^[0-9]"></asp:RegularExpressionValidator>
                </td>
            </tr>
            <tr>
                <td>
                    Amount:-
                </td>
                <td>
                    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                        <ContentTemplate>
                            <asp:TextBox ID="txtAmount" runat="server"  Enabled="false"  EnableTheming="True"></asp:TextBox>
                        </ContentTemplate>
                    </asp:UpdatePanel>
                </td>
            </tr>
        </table>
        <br />
        <br />
        <asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClick="Button1_Click" />
        <br />
        <br />
        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
            onrowcancelingedit="GridView1_RowCancelingEdit"
            onrowdeleting="GridView1_RowDeleting" onrowediting="GridView1_RowEditing"
            onrowupdating="GridView1_RowUpdating"
            onrowdatabound="GridView1_RowDataBound" ShowFooter="true">
            <Columns>
                <asp:TemplateField HeaderText="SR_NO">
                    <ItemTemplate>
                        <asp:Label ID="lblSrno" runat="server" Text='<%# Eval("SR_NO") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Item">
                    <ItemTemplate>
                        <asp:Label ID="lblStcd" runat="server" Text='<%# Eval("ST_DESC") %>'></asp:Label>
                    </ItemTemplate>
                    <EditItemTemplate>
                        <asp:DropDownList ID="ddlstItem1" runat="server">
                        </asp:DropDownList>
                        <asp:Label ID="lblStcd" runat="server" Text='<%# Eval("ST_DESC") %>'
                            Visible="false"></asp:Label>
                    </EditItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="QTY">
                    <ItemTemplate>
                        <asp:Label ID="lblQty" runat="server" Text='<%# Eval("QTY") %>'></asp:Label>
                    </ItemTemplate>

                    <EditItemTemplate>
                        <asp:TextBox ID="txtQty1" runat="server"  AutoPostBack="true"
                            Text='<%# Eval("QTY") %>' ontextchanged="txtQty1_TextChanged"></asp:TextBox>
                    </EditItemTemplate>

                </asp:TemplateField>
                <asp:TemplateField HeaderText="RATE" FooterText="Total">
                    <ItemTemplate>
                        <asp:Label ID="lblRate" runat="server" Text='<%# Eval("RATE") %>'></asp:Label>
                    </ItemTemplate>

                    <EditItemTemplate>
                        <asp:TextBox ID="txtRate1" runat="server" Text='<%# Eval("RATE") %>'
                            ontextchanged="txtRate1_TextChanged" AutoPostBack="True"></asp:TextBox>
                    </EditItemTemplate>

                </asp:TemplateField>
                <asp:TemplateField HeaderText="AMT" >
                    <ItemTemplate>
                        <asp:Label ID="lblAmt" runat="server" Text='<%# Eval("AMT")%>'></asp:Label>
                    </ItemTemplate>

                    <EditItemTemplate>
                        <asp:TextBox ID="txtAmt1" runat="server" Enabled="False"
                            Text='<%# Eval("AMT")%>'></asp:TextBox>
                    </EditItemTemplate>
                    <FooterTemplate>
                        <asp:Label ID="lblSum" runat="server"></asp:Label>
                    </FooterTemplate>
                </asp:TemplateField>

                <asp:CommandField HeaderText="EDIT" ShowEditButton="True" ShowHeader="True" />
                <asp:CommandField HeaderText="DELETE" ShowDeleteButton="True"
                    ShowHeader="True" />

            </Columns>
        </asp:GridView>
    </div>
    </form>
</body>



when i enter the value of chal no at thaat time check enter value is duplicate..
Posted
Updated 30-Jun-13 22:33pm
v3
Comments
AnkitGoel.com 1-Jul-13 4:30am    
where is the code?
VICK 1-Jul-13 4:51am    
You want to check the value duplication from some column of database table??
Mean the value typed in textbox should not be equal to any value in database.. OR you just want to check the duplication against some hardcoded value... Kindly elaborate..
hardikshah011 1-Jul-13 5:10am    
yup

if you want to know that if the currently entered challan number exits in database or not then you may check the number of rows having the challan number as its entry i.e.
C#
DataTable dt;
SqlCommand cmd = new SqlCommand("SELECT * FROM yourtablename WHERE ChallanNum=@challanNum");
SqlDataAdapter adap = new SqlDataAdapter(cmd, con);
adap.Fill(dt);

/*Check if dplicate value exists */
if(dt.rows.count>0)
{
MessageBox.Show("Challan Number Already Exists In Database");

}
else
{
 /*Insert your data */
}

Hope this solution has meet ur requirement
 
Share this answer
 
v2
See if you want to check the challan no. from your database then the above solution (solution 1) is good and you should do it on click event of Submit button of your form as the performance may slow down if you use the text_changed event of your text_box.

One piece of advice if you use the above mentioned code,
please use the query :

SELECT Count(*) FROM yourtablename WHERE ChallanNum=@challanNum;

as it will not fetch all the columns which are not required.

Count(*) will fetch only the number of rows matching the criteria.

Thanks "bunzitop" and hope this solution helps you "hardikshah011".
 
Share this answer
 

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