!gridview insert!?

Discussion in 'ASP .Net' started by merrittr, Jan 18, 2008.

  1. merrittr

    merrittr Guest

    I have a simple wizard generated gridview , and i seem to be unable to
    grasp the intracacies
    to add a insert row.

    I thought the form object would work to insert a row (currently the db
    is empty)
    is the fact that all my fields are set up as bound the issue?????
    WTF I would think this should be easy since generating the edit/select/
    selete
    part was easy



    <asp:FormView ID="FormView1" runat="server" DataKeyNames="Asset_Tag"
    DataSourceID="SqlDataSource1">
    <EditItemTemplate>
    Agency_ID:
    <asp:TextBox ID="Agency_IDTextBox" runat="server"
    Text='<%# Bind("Agency_ID") %>'>
    </asp:TextBox><br />
    Asset_Tag:
    <asp:Label ID="Asset_TagLabel1" runat="server" Text='<
    %# Eval("Asset_Tag") %>'></asp:Label><br />
    Serial_Number:
    <asp:TextBox ID="Serial_NumberTextBox" runat="server"
    Text='<%# Bind("Serial_Number") %>'>
    </asp:TextBox><br />
    ..
    ..
    ..

    <asp:GridView ID="GridView1" runat="server" AllowPaging="True"
    AllowSorting="True"
    AutoGenerateColumns="False" BackColor="White"
    BorderColor="#999999" BorderStyle="None"
    BorderWidth="1px" CellPadding="3" DataKeyNames="Asset_Tag"
    DataSourceID="SqlDataSource1"
    ShowFooter="True" GridLines="Vertical" >
    <FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
    <Columns>
    <asp:CommandField ShowDeleteButton="True" ShowEditButton="True"
    ShowSelectButton="True" />
    <asp:BoundField DataField="Agency_ID" HeaderText="Agency_ID"
    SortExpression="Agency_ID" />
    <asp:BoundField DataField="Asset_Tag" HeaderText="Asset_Tag"
    ReadOnly="True" SortExpression="Asset_Tag" />
    <asp:BoundField DataField="Serial_Number" HeaderText="Serial_Number"
    SortExpression="Serial_Number" />
    <asp:BoundField DataField="Type" HeaderText="Type"
    SortExpression="Type" />
    <asp:BoundField DataField="SubType" HeaderText="SubType"
    SortExpression="SubType" />
    <asp:BoundField DataField="Mfg" HeaderText="Mfg"
    SortExpression="Mfg" />
    <asp:BoundField DataField="Model" HeaderText="Model"
    SortExpression="Model" />
    <asp:BoundField DataField="Description" HeaderText="Description"
    SortExpression="Description" />
    <asp:BoundField DataField="Purchase_Date" HeaderText="Purchase_Date"
    SortExpression="Purchase_Date" />
    <asp:BoundField DataField="Purchase_Cost" HeaderText="Purchase_Cost"
    SortExpression="Purchase_Cost" />
    <asp:BoundField DataField="Acquisition_Type"
    HeaderText="Acquisition_Type" SortExpression="Acquisition_Type" />
    <asp:BoundField DataField="Disposal_Date" HeaderText="Disposal_Date"
    SortExpression="Disposal_Date" />
    <asp:BoundField DataField="Disposal_Reason"
    HeaderText="Disposal_Reason" SortExpression="Disposal_Reason" />
    <asp:BoundField DataField="CPU" HeaderText="CPU"
    SortExpression="CPU" />
    <asp:BoundField DataField="MIPS_or_Mhz" HeaderText="MIPS_or_Mhz"
    SortExpression="MIPS_or_Mhz" />
    <asp:BoundField DataField="Capacity" HeaderText="Capacity"
    SortExpression="Capacity" />
    <asp:BoundField DataField="Asset_ID" HeaderText="Asset_ID"
    SortExpression="Asset_ID" />
    <asp:BoundField DataField="Warranty_End_Date"
    HeaderText="Warranty_End_Date" SortExpression="Warranty_End_Date" />
    <asp:BoundField DataField="Maintenance_End_Date"
    HeaderText="Maintenance_End_Date"
    SortExpression="Maintenance_End_Date" />
    <asp:BoundField DataField="Maintenance_Cost"
    HeaderText="Maintenance_Cost" SortExpression="Maintenance_Cost" />
    <asp:BoundField DataField="Asset_Name" HeaderText="Asset_Name"
    SortExpression="Asset_Name" />
    <asp:BoundField DataField="OS_Version" HeaderText="OS_Version"
    SortExpression="OS_Version" />
    <asp:BoundField DataField="Org" HeaderText="Org"
    SortExpression="Org" />
    <asp:BoundField DataField="Physical_Address"
    HeaderText="Physical_Address" SortExpression="Physical_Address" />
    <asp:BoundField DataField="City" HeaderText="City"
    SortExpression="City" />
    <asp:BoundField DataField="Notes" HeaderText="Notes"
    SortExpression="Notes" />
    </Columns>
    <RowStyle BackColor="#EEEEEE" ForeColor="Black" />
    <SelectedRowStyle BackColor="#008A8C" Font-Bold="True"
    ForeColor="White" />
    <PagerStyle BackColor="#999999" ForeColor="Black"
    HorizontalAlign="Center" />
    <HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" />
    <AlternatingRowStyle BackColor="#DCDCDC" />
    </asp:GridView>
     
    merrittr, Jan 18, 2008
    #1
    1. Advertising

  2. merrittr

    JIGNESH Guest

    GridView by default will now alllow you to insert new records.
    you will need to activate footer section, convert footer into template so
    that you can place few textboxes and button.

    Once done you can write code on button click event to read data from footer
    row
    eg. GridView1.FooterRow.FindControl("TextBox1") as TextBox;

    Need more help feel free to mail me.
    Regards
    JIGNESH


    "merrittr" wrote:

    > I have a simple wizard generated gridview , and i seem to be unable to
    > grasp the intracacies
    > to add a insert row.
    >
    > I thought the form object would work to insert a row (currently the db
    > is empty)
    > is the fact that all my fields are set up as bound the issue?????
    > WTF I would think this should be easy since generating the edit/select/
    > selete
    > part was easy
    >
    >
    >
    > <asp:FormView ID="FormView1" runat="server" DataKeyNames="Asset_Tag"
    > DataSourceID="SqlDataSource1">
    > <EditItemTemplate>
    > Agency_ID:
    > <asp:TextBox ID="Agency_IDTextBox" runat="server"
    > Text='<%# Bind("Agency_ID") %>'>
    > </asp:TextBox><br />
    > Asset_Tag:
    > <asp:Label ID="Asset_TagLabel1" runat="server" Text='<
    > %# Eval("Asset_Tag") %>'></asp:Label><br />
    > Serial_Number:
    > <asp:TextBox ID="Serial_NumberTextBox" runat="server"
    > Text='<%# Bind("Serial_Number") %>'>
    > </asp:TextBox><br />
    > ..
    > ..
    > ..
    >
    > <asp:GridView ID="GridView1" runat="server" AllowPaging="True"
    > AllowSorting="True"
    > AutoGenerateColumns="False" BackColor="White"
    > BorderColor="#999999" BorderStyle="None"
    > BorderWidth="1px" CellPadding="3" DataKeyNames="Asset_Tag"
    > DataSourceID="SqlDataSource1"
    > ShowFooter="True" GridLines="Vertical" >
    > <FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
    > <Columns>
    > <asp:CommandField ShowDeleteButton="True" ShowEditButton="True"
    > ShowSelectButton="True" />
    > <asp:BoundField DataField="Agency_ID" HeaderText="Agency_ID"
    > SortExpression="Agency_ID" />
    > <asp:BoundField DataField="Asset_Tag" HeaderText="Asset_Tag"
    > ReadOnly="True" SortExpression="Asset_Tag" />
    > <asp:BoundField DataField="Serial_Number" HeaderText="Serial_Number"
    > SortExpression="Serial_Number" />
    > <asp:BoundField DataField="Type" HeaderText="Type"
    > SortExpression="Type" />
    > <asp:BoundField DataField="SubType" HeaderText="SubType"
    > SortExpression="SubType" />
    > <asp:BoundField DataField="Mfg" HeaderText="Mfg"
    > SortExpression="Mfg" />
    > <asp:BoundField DataField="Model" HeaderText="Model"
    > SortExpression="Model" />
    > <asp:BoundField DataField="Description" HeaderText="Description"
    > SortExpression="Description" />
    > <asp:BoundField DataField="Purchase_Date" HeaderText="Purchase_Date"
    > SortExpression="Purchase_Date" />
    > <asp:BoundField DataField="Purchase_Cost" HeaderText="Purchase_Cost"
    > SortExpression="Purchase_Cost" />
    > <asp:BoundField DataField="Acquisition_Type"
    > HeaderText="Acquisition_Type" SortExpression="Acquisition_Type" />
    > <asp:BoundField DataField="Disposal_Date" HeaderText="Disposal_Date"
    > SortExpression="Disposal_Date" />
    > <asp:BoundField DataField="Disposal_Reason"
    > HeaderText="Disposal_Reason" SortExpression="Disposal_Reason" />
    > <asp:BoundField DataField="CPU" HeaderText="CPU"
    > SortExpression="CPU" />
    > <asp:BoundField DataField="MIPS_or_Mhz" HeaderText="MIPS_or_Mhz"
    > SortExpression="MIPS_or_Mhz" />
    > <asp:BoundField DataField="Capacity" HeaderText="Capacity"
    > SortExpression="Capacity" />
    > <asp:BoundField DataField="Asset_ID" HeaderText="Asset_ID"
    > SortExpression="Asset_ID" />
    > <asp:BoundField DataField="Warranty_End_Date"
    > HeaderText="Warranty_End_Date" SortExpression="Warranty_End_Date" />
    > <asp:BoundField DataField="Maintenance_End_Date"
    > HeaderText="Maintenance_End_Date"
    > SortExpression="Maintenance_End_Date" />
    > <asp:BoundField DataField="Maintenance_Cost"
    > HeaderText="Maintenance_Cost" SortExpression="Maintenance_Cost" />
    > <asp:BoundField DataField="Asset_Name" HeaderText="Asset_Name"
    > SortExpression="Asset_Name" />
    > <asp:BoundField DataField="OS_Version" HeaderText="OS_Version"
    > SortExpression="OS_Version" />
    > <asp:BoundField DataField="Org" HeaderText="Org"
    > SortExpression="Org" />
    > <asp:BoundField DataField="Physical_Address"
    > HeaderText="Physical_Address" SortExpression="Physical_Address" />
    > <asp:BoundField DataField="City" HeaderText="City"
    > SortExpression="City" />
    > <asp:BoundField DataField="Notes" HeaderText="Notes"
    > SortExpression="Notes" />
    > </Columns>
    > <RowStyle BackColor="#EEEEEE" ForeColor="Black" />
    > <SelectedRowStyle BackColor="#008A8C" Font-Bold="True"
    > ForeColor="White" />
    > <PagerStyle BackColor="#999999" ForeColor="Black"
    > HorizontalAlign="Center" />
    > <HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" />
    > <AlternatingRowStyle BackColor="#DCDCDC" />
    > </asp:GridView>
    >
     
    JIGNESH, Jan 18, 2008
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?bWdvbnphbGVzMw==?=

    GridView Hierarchical View - Gridview in Gridview

    =?Utf-8?B?bWdvbnphbGVzMw==?=, May 9, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    17,982
    =?Utf-8?B?UGhpbGxpcCBXaWxsaWFtcw==?=
    May 9, 2006
  2. cannontrodder
    Replies:
    1
    Views:
    734
    cannontrodder
    Jul 25, 2006
  3. Replies:
    1
    Views:
    456
  4. Replies:
    1
    Views:
    1,789
    Albert Hopkins
    Dec 6, 2008
  5. eagle

    Insert & Insert/Repeat buttons in a detailsview

    eagle, Jul 12, 2007, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    1,062
    eagle
    Jul 12, 2007
Loading...

Share This Page