Solved

Allow data input

Posted on 2013-01-14
5
292 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
Comment Utility
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
Comment Utility
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
Comment Utility
Any help?
0
 
LVL 16

Assisted Solution

by:Rose Babu
Rose Babu earned 200 total points
Comment Utility
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
Comment Utility
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
Envision that you are chipping away at another e-business site with a team of pundit developers and designers. Everything seems, by all accounts, to be going easily.
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

762 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now