Solved

Allow data input

Posted on 2013-01-14
5
304 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Any business that wants to seriously grow needs to keep the needs and desires of an international audience of their websites in mind. Making a website friendly to international users isn’t prohibitively expensive and can provide an incredible return…
There’s a good reason for why it’s called a homepage – it closely resembles that of a physical house and the only real difference is that it’s online. Your website’s homepage is where people come to visit you. It’s the family room of your website wh…
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

733 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