Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Helloo..

I want to insert data from a form to a database.I am using <asp:Formparameter> to insert. but i came to know that formparameter does not support validation.so what can i do now.Please help me out...

here is the code....
C#
protected void btn_click(object sender, EventArgs e)
   {
       if (Page.IsValid)
       {

           srcusers.Insert();
           confirmmsg.Text = "Data Inserted";
       }
       else
       {
           confirmmsg.Text = "Fill carefully";
       }

   }

HTML:
XML
<asp:DetailsView ID="DetailsView1" DataSourceID="srcusers"
               EmptyDataText="No Records present" AllowPaging="true"
              runat="server" Height="50px" Width="125px">
              </asp:DetailsView>

            <asp:SqlDataSource ID="srcusers"
             ConnectionString="<%$ ConnectionStrings:userdatabase %>"
             SelectCommand="SELECT * FROM Curr_Projects"
             InsertCommand="INSERT into Curr_Projects (Portcode,Portname,Proj_Id,Proj_Name,Description,Dateofissue,TargetToachieve,Estimatedcost)
                     VALUES (@Portcode,@Portname,@Proj_Id,@Proj_Name,@Description,@Dateofissue,@TargetToachieve,@Estimatedcost)"
                     runat="server">
                     <InsertParameters>
                        <asp:FormParameter Name="portcode" FormField="tpc" />
                        <asp:FormParameter Name="portname" FormField="tpn" />
                        <asp:FormParameter Name="Proj_id" FormField="tprojno"/>
                        <asp:FormParameter Name="Proj_Name" FormField="tprname" />
                        <asp:FormParameter Name="Description" FormField="tprdesc" />
                        <asp:FormParameter Name="dateofissue" FormField="tdateiss" Type="DateTime" />
                        <asp:FormParameter Name="TargetToachieve" FormField="ttg" />
                        <asp:FormParameter Name="Estimatedcost" FormField="test" />
                     </InsertParameters>
            </asp:SqlDataSource>
Posted
Updated 17-Mar-13 3:38am
v2
Comments
Shubham Choudhary 18-Mar-13 2:09am    
hi try to call method from html page
<asp:button
id="Button1"
runat="server"
text="save"
onclick="your-function-name" />
ZurdoDev 22-Mar-13 11:50am    
Just write your own validation code.

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