adding rows to dataset using templates in datagrid

G

Guest

I am sure this is suppose to be easy but I keep missing something. I created a dataset with one table. I have a datagrid made up of template columns. I use the footer to add records. I can do this fine using dataadapter and updating database. What I need to do in this case is create the all the dta before writing to the database. Anyway. I can insert the first record - it displays in datagrid and uses the values from the datagrid. It will not accept a new record. No let me rephrase that. It takes the new record and displays it but the previous will not display.
Any help would be appreciated
below is the code

Sub dg_Details_Add_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles dg_Details_Add.ItemComman
If e.CommandName = "Insert" The
Dim txtdesc As TextBo
Dim txtqty As TextBo
Dim txtcost As TextBo
Dim strdesc As Strin
Dim intqty As Intege
Dim deccost As Decima

txtdesc = e.Item.FindControl("txt_add_desc"
strdesc = txtdesc.Tex

txtqty = e.Item.FindControl("txt_add_qty"
intqty = CType(txtqty.Text, Integer

txtcost = e.Item.FindControl("txt_add_cost"
deccost = CType(txtcost.Text, Decimal

Dim detailrow As DataRow = table_details.NewRo
detailrow("Description") = strdes
detailrow("Qty") = intqt
detailrow("Cost") = deccos
table_details.Rows.Add(detailrow

ds_add_details.GetChanges(
dg_Details_Add.DataBind(

Dim curRows() As DataRo
curRows = table_details.Select(Nothing, Nothing, DataViewRowState.CurrentRows
Response.Write(curRows

End I
End Su

<asp:datagrid id=dg_Details_Add style="Z-INDEX: 118; LEFT: 344px; POSITION: absolute; TOP: 56px" runat="server" Width="640px" AutoGenerateColumns="False" ShowFooter="True" DataSource="<%# ds_add_details %>" GridLines="None" DataMember="table_details"><Columns><asp:TemplateColumn HeaderText="Description"><ItemTemplate><asp:Label id=Label15 runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.Description") %>'></asp:Label></ItemTemplate><FooterTemplate><asp:TextBox id="txt_add_desc" runat="server" Width="224px"></asp:TextBox></FooterTemplate><EditItemTemplate><asp:TextBox id=txt_edit_desc runat="server" Width="224px" Text='<%# DataBinder.Eval(Container, "DataItem.Description") %>'></asp:TextBox></EditItemTemplate></asp:TemplateColumn><asp:TemplateColumn HeaderText="Qty"><ItemTemplate><asp:Label id=lbl_dg_qty runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.Qty") %>'></asp:Label></ItemTemplate><FooterTemplate><asp:TextBox id="txt_add_qty" runat="server" Width="48px"></asp:TextBox></FooterTemplate><EditItemTemplate><asp:TextBox id=txt_edit_qty runat="server" Width="48px" Text='<%# DataBinder.Eval(Container, "DataItem.Qty") %>'></asp:TextBox></EditItemTemplate></asp:TemplateColumn><asp:TemplateColumn HeaderText="Cost"><ItemTemplate><asp:Label id=Label16 runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.Cost", "{0:C}") %>'></asp:Label></ItemTemplate><FooterTemplate><asp:TextBox id="txt_add_cost" runat="server" Width="56px"></asp:TextBox></FooterTemplate><EditItemTemplate><asp:TextBox id=txt_edit_cost runat="server" Width="56px" Text='<%# DataBinder.Eval(Container, "DataItem.Cost", "{0:C}") %>'></asp:TextBox></EditItemTemplate></asp:TemplateColumn><asp:TemplateColumn><ItemTemplate><asp:LinkButton id="LinkButton1" runat="server" Text="Edit" CommandName="Edit" CausesValidation="false"></asp:LinkButton></ItemTemplate><FooterTemplate><asp:LinkButton id="lb_add" runat="server" CommandName="Insert">Add Item </asp:LinkButton></FooterTemplate><EditItemTemplate><asp:LinkButton id="LinkButton3" runat="server" Text="Update" CommandName="Update"></asp:LinkButton>&nbsp
<asp:LinkButton id="LinkButton2" runat="server" Text="Cancel" CommandName="Cancel" CausesValidation="false"></asp:LinkButton></EditItemTemplate></asp:TemplateColumn></Columns></asp:datagrid>
 
C

Cor

Hi Amy,

For the webdatagrid are mostly not so many experts in this newsgroup active.

When I was you I would try it in the newsgroups

microsoft.public.dotnet.framework.aspnet
or/and (crossposted)
microsoft.public.dotnet.framework.aspent.datagridcontrol

I hope this helps?

Cor
 

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

Top