how do you get data out of a detailsview

G

Guest

I'm using a detailsview to insert a record, should be simple enough? What
am I doing wrong? Thank you for your help.

The user fills in all the textboxes and hits insert.
I've tried every event there is to retrieve cells and rows and I've even
converted some of the fields from bound controls to templates, and all the
data is blank no matter what I do:

<asp:DetailsView ID="dvBillingServiceInsert" runat="server"
GridLines="None"
AutoGenerateRows="False" DefaultMode="Insert" Width="722px"
BackColor="White"
BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px"
CellPadding="3">
<Fields>
<asp:TemplateField SortExpression="Section" HeaderText="Section:">
<ItemTemplate>
<asp:Label ID="lblSection" runat="server" Text='<%#
Bind("SectionName") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtNewSection"
runat="server"></asp:TextBox>
<br />
</EditItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="FirstName" HeaderText="First Name:" />
<asp:BoundField DataField="LastName" HeaderText="Last Name:" />
<asp:CommandField ShowInsertButton="True" />
</Fields>
<FooterStyle BackColor="White" ForeColor="#000066" />
<RowStyle ForeColor="#000066" />
<PagerStyle BackColor="White" ForeColor="#000066"
HorizontalAlign="Left" />
<HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White"
/>
</asp:DetailsView>


Code Behind (I have tried every event, the itemInserting event, the
itemUpdating, the prerender, databound, every every every event there is for
the detailsview), and the values are all "" even though I have put data in
the cells:

Dim row As DetailsViewRow = Sender.Rows(1)
Dim str as String = row.Cells(1).text
Dim item as New ListItem(str)
ListBox1.Items.Add(item)

Dim row2 As DetailsViewRow = Sender.Rows(2)
Dim str2 as String = row2.Cells(1).text
Dim item2 as New ListItem(str2)
ListBox1.Items.Add(item2)


Dim item4 as New ListItem("testing")
listbox1.Items.Add(item4)
 

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

Forum statistics

Threads
473,968
Messages
2,570,154
Members
46,702
Latest member
LukasConde

Latest Threads

Top