p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   ASP.NET 1.0 and 1.1 Professional (http://p2p.wrox.com/forumdisplay.php?f=57)
-   -   Problem with datagrid inside a datalist (http://p2p.wrox.com/showthread.php?t=11228)

hoeknu March 31st, 2004 07:22 AM

Problem with datagrid inside a datalist

I have I datagrid nested within a datalist, and my problem is that I can`t seem to find a way to get the values (using VB.NET) from the controls inside the datagrid. (textbox etc).
Can anyone please help?


Here is a code snippet from my aspx file:

<asp:datalist id="dataliste" Runat="server" CellSpacing="2" DataKeyField="emneId" OnEditCommand="endreKategori" OnDeleteCommand="slettKategori" OnCancelCommand="cancel">

<asp:LinkButton Text='<%# Container.DataItem("emne")%>' Runat="server" CommandName="Show" id="btnVisKat">
<asp:Label Runat="server" id="lblEmne" visible="False" text='<%# Container.DataItem("emne")%>' >
<asp:DataGrid Runat="server" id="datagrid" visible="False" AutoGenerateColumns="False" OnEditCommand="endreKlikk" OnCancelCommand="cancelKlikk" OnDeleteCommand="deleteKlikk" OnUpdateCommand="updateKlikk">

<asp:EditCommandColumn ItemStyle-Width="25px" EditText="<img border=0 Alt='Endre kategori' src=../../img/Edit.gif>" CancelText="<img border=0 src=../../img/Cancel.gif>" UpdateText="<img border=0 src=../../img/OK.gif>" />

<asp:ButtonColumn ItemStyle-Width="25px" Text="<img border=0 Alt='Slette kategori' src=../../img/Delete.gif>" CommandName="delete" />

<asp:TemplateColumn HeaderText="Kategori" HeaderStyle-Font-Bold="True" SortExpression="Kategori" ItemStyle-Width="150px">


<asp:Label id="Label1" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "kategori") %>' />

<asp:TextBox id="txtEndreKategori" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "kategori") %>' Width="150px" />
<asp:RequiredFieldValidator Id="ValidateEditName" runat="server" ControlToValidate="txtEndreKategori" Display="dynamic">
* Kategori må fylles ut


planoie April 3rd, 2004 11:17 PM

Where/when are you trying to get the values out? You haven't detailed this so it's hard to provide an answer.

Hadware April 4th, 2006 10:11 PM

I also have a datagrid inside of a datalist where I am trying to fill the datagrid with the key from the datalist.

The datagrid is in the edititemtemplate. I fill the datalist with a dataset first, then clicking on the linkbutton for editing I would need the datagrid to fill.

Where would I do this?


Hadware April 4th, 2006 10:45 PM

Here's what I have so far...
    Sub DataList_EditCommand(ByVal sender As Object, ByVal e As DataListCommandEventArgs)
        DataList1.EditItemIndex = e.Item.ItemIndex
        Dim thegrid As DataGrid
        Dim intID As Integer
        intID = DataList1.DataKeys(e.Item.ItemIndex)
        thegrid = CType(e.Item.FindControl("DataGrid1"), DataGrid)
        Dim queryString As String = "displayadscreditsearnedfrom " & intID
        Dim cmd As New SqlCommand(queryString, connect)

        Dim dataAdapter As SqlDataAdapter = New SqlDataAdapter(cmd)
        Dim data As DataSet = New DataSet
        thegrid.DataSource = data
    End Sub

It tells me I cannot convert to double.

All times are GMT -4. The time now is 12:39 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.