TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Kamala Veni
NA
65
21.5k
validation comparevalidator FOR BIND TEXTBOX in gridview
Jul 8 2016 4:16 AM
Hi
I bind the data in textbox in the gridview from the SQL table. in that i gonna edit only one textbox using edit and delete option.
so i gonna edit the valuer in the textbox,its should not greater than old value.i can able to do that in table method,bt nt in gridview.
it should editable as per the user values.its not constant value,it ll change as the username,Id
ex:
<div>
<table>
<tr>
<th class="auto-style3"><asp:Label ID="lb" runat="server" Text="U NAME"></asp:Label></th>
<td><asp:Label ID="lbus" runat="server" Text='<%# Eval("[USER NAME]")%>'></asp:Label></td>
</tr>
<tr>
<th class="auto-style3"><asp:Label ID="Label1" runat="server" Text="NAME"></asp:Label></th>
<td><asp:Label ID="lbcp" runat="server" Text='<%# Eval("[COMPANYNAME]")%>'></asp:Label></td>
</tr>
<tr>
<th class="auto-style3"><asp:Label ID="lb2" runat="server" Text="CPP QTM"></asp:Label></th>
<td><asp:TextBox runat="server" id="txtBigNumber" Text='<%# Eval("CPPQUANTUM_C")%>' ReadOnly="true"/></td>
<td><asp:TextBox runat="server" id="txtSmallNumber" />
<asp:CompareValidator runat="server" id="cmpNumbers" controltovalidate="txtSmallNumber" controltocompare="txtBigNumber" operator="LessThan" type="Integer" errormessage="The Second number should be smaller than the First number!" /><br />
</td>
</tr>
</table>
</div>
public partial class f : System.Web.UI.Page
{
SqlConnection con = new SqlConnection("data source=VAAYUSEVA_SVR;Initial Catalog=cppsch;User ID=sa;Password=sa");
public static string x;
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
string un = Session["Uname"].ToString();
string q = "select * from TBL_CPPMASTER where [USER NAME]='" + un + "'";
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["cppschConnectionString"].ConnectionString);
con.Open();
SqlCommand cmd = new SqlCommand(q, con);
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
txtBigNumber.Text = dr["CPPQUANTUM_C"].ToString();
}
}
}
for grid view: btis nt wrking:
<asp:GridView ID="gridView" runat="server"
AutoGenerateColumns="false" ShowFooter="true" HeaderStyle-Font-Bold="true"
onrowcancelingedit="gridView_RowCancelingEdit" DataKeyNames="Id"
onrowdeleting="gridView_RowDeleting" HeaderStyle-BackColor="#E9E9E9"
onrowediting="gridView_RowEditing"
onrowupdating="gridView_RowUpdating"
onrowcommand="gridView_RowCommand"
OnRowDataBound="gridView_RowDataBound" style="margin-left: 0px" >
<Columns>
<asp:TemplateField HeaderText="S No" >
<ItemTemplate>
<asp:Label ID="txtstorid" runat="server" Text='<%#Eval("[Id]") %>' Width="60px"/>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="CPP QTM" >
<ItemTemplate>
<asp:TextBox ID="txtBigNumber" runat="server" Text='<%# Eval("CPPQUANTUM_C")%>' /><
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtcpc" runat="server" width="40px" Text='<%#Eval("[CPPQUANTUM_C]") %>' MaxLength="4" onkeypress="return onlyNos(event,this);"></asp:TextBox>
<asp:CompareValidator runat="server" id="cmpNumbers" controltovalidate="txtcpc" controltocompare="txtBigNumber" operator="LessThan" type="Integer" errormessage="The Second number should be smaller than the First number!" /><br />
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="incpc" runat="server" width="40px" MaxLength="5" onkeypress="return onlyNos(event,this);" ></asp:TextBox>
<asp:RequiredFieldValidator ID="rfvcpcc" runat="server" ControlToValidate="incpc" Text="*" ForeColor="Red" Font-Bold="true" Font-Size="Large" ValidationGroup="validaiton" />
</FooterTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
please help me...i need exact code.....
Reply
Answers (
2
)
How to retrieve tree view based on id from database table
Best way for offline/online application &remote Database