Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Allow data input

Posted on 2013-01-14
5
302 Views
Last Modified: 2013-01-23
Hi,
I defined a "Formview" on the page like the following. How to allow data insert when there is no records?
    ...
    <asp:FormView ID="lan_gv" runat="server"
    AutoGenerateColumns="false"
    HeaderStyle-BorderStyle="Double"
    BorderWidth="2px"
    Font-Size="Small"
    ForeColor="DarkBlue"
    BackColor="#1BE0D6"
    BorderStyle="Groove"
    AllowSorting="True"
    Title="Test"
    datasourceid="ds_int" >
    <EmptyDataTemplate>
    <asp:Image ID="im1" AlternateText="No Data" runat="server" />
    </EmptyDataTemplate>
    <HeaderStyle BackColor="#1BE0D6">
    </HeaderStyle>
    <EditItemTemplate>
    <asp:DropDownList ID="int_list"
        runat="server"
        BackColor="#1BE0D6"
        DataTextField="Language"
        DataValueField="language" >
    </asp:DropDownList>
    <asp:Textbox id="change_date" Text='<%# Bind("change_date") %>' runat="server" />
    </EditItemTemplate>
    </asp:FormView>
    ...
0
Comment
Question by:HuaMinChen
5 Comments
 
LVL 39

Expert Comment

by:Pratima Pharande
ID: 38777311
here you will get example of how to insert data using formview

http://sfvt.wordpress.com/2010/09/06/asp-net-tutorial-formview-insert-to-database/
0
 
LVL 10

Author Comment

by:HuaMinChen
ID: 38777321
Thanks. But what change needs to be applied to the above codes to make data insert available to the user doing the input?
0
 
LVL 10

Author Comment

by:HuaMinChen
ID: 38781275
Any help?
0
 
LVL 16

Assisted Solution

by:Rose Babu
Rose Babu earned 200 total points
ID: 38792962
can you check the below tutorial to edit/update/insert data from FormView as you need

http://www.dotnetfunda.com/articles/article991-formview-in-edit-insert-readonly-mode.aspx
0
 
LVL 10

Accepted Solution

by:
Monica P earned 300 total points
ID: 38799904
Hi..

You can change the FormViewMode to insert if there is no record from your datasource.
<asp:FormView ID="FormView1" runat="server" OnDataBound="FormView1_OnDataBound" >

protected void FormView1_OnDataBound(object sender, EventArgs e)
    {
        if (FormView1.PageCount == 0)
        {
            FormView1.ChangeMode(FormViewMode.Insert);

        }
      }

To get more info
********************
Have look on this article for Insert update and delete

http://www.c-sharpcorner.com/blogs/7227/insert-update-and-delete-using-a-formview.aspx
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I've been asked to discuss some of the UX activities that I'm using with my team. Here I will share some details about how we approach UX projects.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
The viewer will learn how to dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question