Solved

Allow data input

Posted on 2013-01-14
5
306 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
[X]
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
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 11

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 11

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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Learn by example how to specify CSS selectors for Selenium WebDriver test automation software.
Because your company can’t afford for you to make SEO mistakes, you’ll want to ensure you’re taking the right steps each and every time you post a new piece of content. This list of optimization do’s and don’ts can help you become an SEO wizard.
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

719 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