!gridview insert!?

M

merrittr

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>
 
J

JIGNESH

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,818
Messages
2,569,727
Members
45,664
Latest member
Phil79581

Latest Threads

Top