I have 2 datagrids, both with databound columns that I have dynamically
added. I have an EditCommandColu mn on both grids. EnableViewState is
enabled on both of the grids.
When I click the edit link on the grids I need to repopulate/rebind the
grids which I presume is correct.
When I click the update button I cannot find my databound columns that I
have edited. I have searched google and tried all the obvious examples, but
I am just not getting it. Is there perhaps a bug, or a limitation with
having 2 grids on one page. What exactly does EnableViewState do anyway if
it doesn't retain the data or already loaded in the grids? Here is my code
for populating one of the grids - the other is very similiar. If anyone has
any idea then please let me know as I am really stuck now...
Page Load....
dgPhotos.AutoGe nerateColumns = False
If dgPhotos.Column s.Count = 5 Then
' Create ID column & add to DataGrid
Dim col1 As New BoundColumn
col1.HeaderText = "Descriptio n"
col1.DataField = "PhotoText"
dgPhotos.Column s.Add(col1)
col1 = Nothing
Dim col2 As New BoundColumn
col2.HeaderText = "Filename"
col2.DataField = "Filename"
col2.ReadOnly = True
dgPhotos.Column s.Add(col2)
col2 = Nothing
Dim col3 As New BoundColumn
col3.HeaderText = "Order"
col3.DataField = "OrderPos"
col3.ReadOnly = True
col3.Visible = False
dgPhotos.Column s.Add(col3)
col3 = Nothing
End If
dsPhotos.ReadXm l(filePath)
dgPhotos.Visibl e = False
If dsPhotos.Tables .Count > 0 Then
dgPhotos.Visibl e = True
Dim lngID As Long
lngID = GetAlbumID(dsPh otos, strRoleID)
dvPhotos.Table = dsPhotos.Tables (1)
dvPhotos.RowFil ter = "AlbumRoleI D_Id = '" & lngID & "'"
dvPhotos.Sort = "OrderPos"
With dgPhotos
.DataSource = dvPhotos
.DataMember = "PhotoItem"
.DataBind()
End With
End If
Editing Code:
Private Sub dgPhotos_EditCo mmand(ByVal source As Object, ByVal e As
System.Web.UI.W ebControls.Data GridCommandEven tArgs) Handles
dgPhotos.EditCo mmand
dgPhotos.EditIt emIndex = e.Item.ItemInde x
Dim strRoleID As String
PopulateGrid() 'Rebinds also
End Sub
Update Code so far :
Private Sub dgPhotos_Update Command(ByVal source As Object, ByVal e As
System.Web.UI.W ebControls.Data GridCommandEven tArgs) Handles
dgPhotos.Update Command
Dim txtDescription As New TextBox
txtDescription = CType(e.Item.Ce lls(1).FindCont rol("PhotoText" ),
TextBox)
End Sub
aspx...
<asp:datagrid id="dgPhotos" runat="server" CssClass="aspTa ble"
ForeColor="Blac k" Font-Size="XX-Small"
AutoGenerateCol umns="False" PageSize="15" Width="100%"
CellSpacing="2" AllowPaging="Tr ue" BorderColor="#9 99999"
BorderStyle="So lid" BorderWidth="3p x" BackColor="#CCC CCC"
CellPadding="4" >
<SelectedItemSt yle Font-Size="XX-Small" Font-Bold="True"
ForeColor="Whit e" BackColor="#000 099"></SelectedItemSty le>
<EditItemStyl e Font-Size="XX-Small"></EditItemStyle>
<AlternatingIte mStyle Font-Size="XX-Small"></AlternatingItem Style>
<ItemStyle Font-Size="XX-Small" BackColor="Whit e"></ItemStyle>
<HeaderStyle Font-Size="XX-Small" Font-Bold="True" ForeColor="Whit e"
BackColor="Blac k"></HeaderStyle>
<FooterStyle Font-Size="XX-Small" BackColor="#CCC CCC"></FooterStyle>
<Columns>
<asp:ButtonColu mn Text="Up" ButtonType="Pus hButton"
CommandName="Up "></asp:ButtonColum n>
<asp:ButtonColu mn Text="Down" ButtonType="Pus hButton"
CommandName="Do wn"></asp:ButtonColum n>
<asp:EditComman dColumn ButtonType="Lin kButton" UpdateText="Upd ate"
CancelText="Can cel" EditText="Edit" >
<HeaderStyle Font-Size="XX-Small"></HeaderStyle>
<ItemStyle Font-Size="XX-Small"></ItemStyle>
<FooterStyle Font-Size="XX-Small"></FooterStyle>
</asp:EditCommand Column>
<asp:ButtonColu mn Text="Delete" CommandName="De lete">
<HeaderStyle Font-Size="XX-Small"></HeaderStyle>
<ItemStyle Font-Size="XX-Small"></ItemStyle>
<FooterStyle Font-Size="XX-Small"></FooterStyle>
</asp:ButtonColum n>
<asp:TemplateCo lumn HeaderText="Pho to">
<ItemTemplate >
<asp:Image runat=server
ImageUrl='<%#Re turnSmallURL(Da taBinder.Eval(c ontainer.datait em, "filename") ,
dgAlbums.Items( dgAlbums.Select edIndex).Cells. Item(7).Text)%> ' ID="Image2"/>
</ItemTemplate>
</asp:TemplateCol umn>
</Columns>
<PagerStyle Font-Size="XX-Small" HorizontalAlign ="Left"
ForeColor="Blac k" BackColor="#CCC CCC"
Mode="NumericPa ges"></PagerStyle>
</asp:datagrid> 2 1216
the Page Load fires again BEFORE the UpdateCommand event ... be sure to only
'fill' the grid if the page is not posted back ...
use:
if not ispostback then
'do stuff
end if
"Philip Rayne" <pr****@noemail .com> wrote in message
news:vd******** **********@cycl ops.nntpserver. com... I have 2 datagrids, both with databound columns that I have dynamically added. I have an EditCommandColu mn on both grids. EnableViewState is enabled on both of the grids.
When I click the edit link on the grids I need to repopulate/rebind the grids which I presume is correct.
When I click the update button I cannot find my databound columns that I have edited. I have searched google and tried all the obvious examples,
but I am just not getting it. Is there perhaps a bug, or a limitation with having 2 grids on one page. What exactly does EnableViewState do anyway
if it doesn't retain the data or already loaded in the grids? Here is my
code for populating one of the grids - the other is very similiar. If anyone
has any idea then please let me know as I am really stuck now...
Page Load....
dgPhotos.AutoGe nerateColumns = False If dgPhotos.Column s.Count = 5 Then
' Create ID column & add to DataGrid Dim col1 As New BoundColumn col1.HeaderText = "Descriptio n" col1.DataField = "PhotoText" dgPhotos.Column s.Add(col1) col1 = Nothing
Dim col2 As New BoundColumn col2.HeaderText = "Filename" col2.DataField = "Filename" col2.ReadOnly = True dgPhotos.Column s.Add(col2) col2 = Nothing
Dim col3 As New BoundColumn col3.HeaderText = "Order" col3.DataField = "OrderPos" col3.ReadOnly = True col3.Visible = False dgPhotos.Column s.Add(col3) col3 = Nothing End If
dsPhotos.ReadXm l(filePath)
dgPhotos.Visibl e = False If dsPhotos.Tables .Count > 0 Then
dgPhotos.Visibl e = True
Dim lngID As Long lngID = GetAlbumID(dsPh otos, strRoleID)
dvPhotos.Table = dsPhotos.Tables (1) dvPhotos.RowFil ter = "AlbumRoleI D_Id = '" & lngID & "'" dvPhotos.Sort = "OrderPos"
With dgPhotos .DataSource = dvPhotos .DataMember = "PhotoItem" .DataBind() End With End If
Editing Code:
Private Sub dgPhotos_EditCo mmand(ByVal source As Object, ByVal e As System.Web.UI.W ebControls.Data GridCommandEven tArgs) Handles dgPhotos.EditCo mmand dgPhotos.EditIt emIndex = e.Item.ItemInde x
Dim strRoleID As String PopulateGrid() 'Rebinds also
End Sub
Update Code so far :
Private Sub dgPhotos_Update Command(ByVal source As Object, ByVal e As System.Web.UI.W ebControls.Data GridCommandEven tArgs) Handles dgPhotos.Update Command
Dim txtDescription As New TextBox txtDescription = CType(e.Item.Ce lls(1).FindCont rol("PhotoText" ), TextBox)
End Sub
aspx... <asp:datagrid id="dgPhotos" runat="server" CssClass="aspTa ble" ForeColor="Blac k" Font-Size="XX-Small" AutoGenerateCol umns="False" PageSize="15" Width="100%" CellSpacing="2" AllowPaging="Tr ue" BorderColor="#9 99999" BorderStyle="So lid" BorderWidth="3p x" BackColor="#CCC CCC" CellPadding="4" > <SelectedItemSt yle Font-Size="XX-Small" Font-Bold="True" ForeColor="Whit e" BackColor="#000 099"></SelectedItemSty le> <EditItemStyl e Font-Size="XX-Small"></EditItemStyle> <AlternatingIte mStyle Font-Size="XX-Small"></AlternatingItem Style> <ItemStyle Font-Size="XX-Small" BackColor="Whit e"></ItemStyle> <HeaderStyle Font-Size="XX-Small" Font-Bold="True"
ForeColor="Whit e" BackColor="Blac k"></HeaderStyle> <FooterStyle Font-Size="XX-Small"
BackColor="#CCC CCC"></FooterStyle> <Columns> <asp:ButtonColu mn Text="Up" ButtonType="Pus hButton" CommandName="Up "></asp:ButtonColum n> <asp:ButtonColu mn Text="Down" ButtonType="Pus hButton" CommandName="Do wn"></asp:ButtonColum n> <asp:EditComman dColumn ButtonType="Lin kButton"
UpdateText="Upd ate" CancelText="Can cel" EditText="Edit" > <HeaderStyle Font-Size="XX-Small"></HeaderStyle> <ItemStyle Font-Size="XX-Small"></ItemStyle> <FooterStyle Font-Size="XX-Small"></FooterStyle> </asp:EditCommand Column> <asp:ButtonColu mn Text="Delete" CommandName="De lete"> <HeaderStyle Font-Size="XX-Small"></HeaderStyle> <ItemStyle Font-Size="XX-Small"></ItemStyle> <FooterStyle Font-Size="XX-Small"></FooterStyle> </asp:ButtonColum n> <asp:TemplateCo lumn HeaderText="Pho to"> <ItemTemplate > <asp:Image runat=server ImageUrl='<%#Re turnSmallURL(Da taBinder.Eval(c ontainer.datait em,
"filename") , dgAlbums.Items( dgAlbums.Select edIndex).Cells. Item(7).Text)%> '
ID="Image2"/> </ItemTemplate> </asp:TemplateCol umn> </Columns> <PagerStyle Font-Size="XX-Small" HorizontalAlign ="Left" ForeColor="Blac k" BackColor="#CCC CCC" Mode="NumericPa ges"></PagerStyle> </asp:datagrid>
Hi, thanks for the info. I was already doing that.
I have now sorted the problem, but I don't really understand why it didn't
work in the first place.
Basically I have now removed the code that adds the columns in the code and
created them in the asp instead :
DataField="Phot oText" />
<asp:BoundColum n HeaderText="Fil ename" SortExpression= "Filename"
DataField="File name" ReadOnly="True" />
<asp:BoundColum n HeaderText="Ord er" SortExpression= "OrderPos"
DataField="Orde rPos" ReadOnly="True"
This now seems to work when I try and access the value of the edited cell.
"Thomas Dodds" <th*********@ho tmail.com> wrote in message
news:e4******** ******@TK2MSFTN GP11.phx.gbl... the Page Load fires again BEFORE the UpdateCommand event ... be sure to
only 'fill' the grid if the page is not posted back ...
use:
if not ispostback then 'do stuff end if
"Philip Rayne" <pr****@noemail .com> wrote in message news:vd******** **********@cycl ops.nntpserver. com... I have 2 datagrids, both with databound columns that I have dynamically added. I have an EditCommandColu mn on both grids. EnableViewState is enabled on both of the grids.
When I click the edit link on the grids I need to repopulate/rebind the grids which I presume is correct.
When I click the update button I cannot find my databound columns that I have edited. I have searched google and tried all the obvious examples, but I am just not getting it. Is there perhaps a bug, or a limitation with having 2 grids on one page. What exactly does EnableViewState do anyway if it doesn't retain the data or already loaded in the grids? Here is my code for populating one of the grids - the other is very similiar. If anyone has any idea then please let me know as I am really stuck now...
Page Load....
dgPhotos.AutoGe nerateColumns = False If dgPhotos.Column s.Count = 5 Then
' Create ID column & add to DataGrid Dim col1 As New BoundColumn col1.HeaderText = "Descriptio n" col1.DataField = "PhotoText" dgPhotos.Column s.Add(col1) col1 = Nothing
Dim col2 As New BoundColumn col2.HeaderText = "Filename" col2.DataField = "Filename" col2.ReadOnly = True dgPhotos.Column s.Add(col2) col2 = Nothing
Dim col3 As New BoundColumn col3.HeaderText = "Order" col3.DataField = "OrderPos" col3.ReadOnly = True col3.Visible = False dgPhotos.Column s.Add(col3) col3 = Nothing End If
dsPhotos.ReadXm l(filePath)
dgPhotos.Visibl e = False If dsPhotos.Tables .Count > 0 Then
dgPhotos.Visibl e = True
Dim lngID As Long lngID = GetAlbumID(dsPh otos, strRoleID)
dvPhotos.Table = dsPhotos.Tables (1) dvPhotos.RowFil ter = "AlbumRoleI D_Id = '" & lngID & "'" dvPhotos.Sort = "OrderPos"
With dgPhotos .DataSource = dvPhotos .DataMember = "PhotoItem" .DataBind() End With End If
Editing Code:
Private Sub dgPhotos_EditCo mmand(ByVal source As Object, ByVal e As System.Web.UI.W ebControls.Data GridCommandEven tArgs) Handles dgPhotos.EditCo mmand dgPhotos.EditIt emIndex = e.Item.ItemInde x
Dim strRoleID As String PopulateGrid() 'Rebinds also
End Sub
Update Code so far :
Private Sub dgPhotos_Update Command(ByVal source As Object, ByVal e As System.Web.UI.W ebControls.Data GridCommandEven tArgs) Handles dgPhotos.Update Command
Dim txtDescription As New TextBox txtDescription = CType(e.Item.Ce lls(1).FindCont rol("PhotoText" ), TextBox)
End Sub
aspx... <asp:datagrid id="dgPhotos" runat="server" CssClass="aspTa ble" ForeColor="Blac k" Font-Size="XX-Small" AutoGenerateCol umns="False" PageSize="15" Width="100%" CellSpacing="2" AllowPaging="Tr ue" BorderColor="#9 99999" BorderStyle="So lid" BorderWidth="3p x" BackColor="#CCC CCC" CellPadding="4" > <SelectedItemSt yle Font-Size="XX-Small" Font-Bold="True" ForeColor="Whit e" BackColor="#000 099"></SelectedItemSty le> <EditItemStyl e Font-Size="XX-Small"></EditItemStyle> <AlternatingIte mStyle
Font-Size="XX-Small"></AlternatingItem Style> <ItemStyle Font-Size="XX-Small" BackColor="Whit e"></ItemStyle> <HeaderStyle Font-Size="XX-Small" Font-Bold="True" ForeColor="Whit e" BackColor="Blac k"></HeaderStyle> <FooterStyle Font-Size="XX-Small" BackColor="#CCC CCC"></FooterStyle> <Columns> <asp:ButtonColu mn Text="Up" ButtonType="Pus hButton" CommandName="Up "></asp:ButtonColum n> <asp:ButtonColu mn Text="Down" ButtonType="Pus hButton" CommandName="Do wn"></asp:ButtonColum n> <asp:EditComman dColumn ButtonType="Lin kButton" UpdateText="Upd ate" CancelText="Can cel" EditText="Edit" > <HeaderStyle Font-Size="XX-Small"></HeaderStyle> <ItemStyle Font-Size="XX-Small"></ItemStyle> <FooterStyle Font-Size="XX-Small"></FooterStyle> </asp:EditCommand Column> <asp:ButtonColu mn Text="Delete" CommandName="De lete"> <HeaderStyle Font-Size="XX-Small"></HeaderStyle> <ItemStyle Font-Size="XX-Small"></ItemStyle> <FooterStyle Font-Size="XX-Small"></FooterStyle> </asp:ButtonColum n> <asp:TemplateCo lumn HeaderText="Pho to"> <ItemTemplate > <asp:Image runat=server ImageUrl='<%#Re turnSmallURL(Da taBinder.Eval(c ontainer.datait em, "filename") , dgAlbums.Items( dgAlbums.Select edIndex).Cells. Item(7).Text)%> ' ID="Image2"/> </ItemTemplate> </asp:TemplateCol umn> </Columns> <PagerStyle Font-Size="XX-Small" HorizontalAlign ="Left" ForeColor="Blac k" BackColor="#CCC CCC" Mode="NumericPa ges"></PagerStyle> </asp:datagrid>
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: |
last post by:
I have a web page written in asp.net that has multiple datagrids on it that
would need to be exported to Excel. Each of the datagrids would be a subset
of what the datagrid above it was.
Thus far, I've had no luck in finding anything to work reliably. Some of
the files I've saved (using a radio button click event), will open fine in
Excel, others give me an "Unable to open file" message.
Any help appreciated.
|
by: mark |
last post by:
I have one page with a series of reports to be printed like :-
(bear with me ill try to explain the best i can!)
report one - checkbox1
report two - checkbox2
report three - checkbox3
and so on
finally a button to process the reports is pressed
|
by: Paul King |
last post by:
Hi there,
I want to create a page for our site so that our customers can go online and
give us feedback. The page will consist namely of text boxes, combo lists
and radio buttons.
Ive been using DataGrids to insert records into our SQL box and can design
the page using this method in ASP.net
However I was wondering if there was a better method or do people use other
|
by: ree32 |
last post by:
I have a placeholder and depending on a user input(a drop downlist)
when the user clicks a button I dynamically create a number of
datagrids and fill them with data from a database. But the problem is
that on a postback I lose all the datagrids and their data.
I have looked at numerous pages on the net regarding this issue. Many
say you have to rebuild build the controls on postback. How am I meant
to do this in my situation as I don't...
|
by: Anna |
last post by:
Hi there,
I have a master/detail page that I've created using a datagrid inside a
repeater. I need to find a way to export the entire resulting web page
into Excel, and the multiple datagrids are giving me problems. I need
each one to have a unique name that I can refer to in the code I'm
using to generate the Excel.
Any ideas on how I can name the datagrids? I'm happy to provide more
details if necessary.
| |
by: Steve Hershoff |
last post by:
Hi everyone,
I've got a strange one here. There are two datagrids on my page, one nested
within the other. I'll refer to them as the topmost and secondary
datagrids.
In the topmost datagrid's OnItemDataBound() method we check for the row in
which it's appropriate to add the secondary datagrid. Exactly one row in
the topmost grid will contain the secondary grid.
|
by: rn5a |
last post by:
In a shopping cart app, a ASPX page retrieves the order details &
personal details of a user from a MS-Access database table depending
upon the username of the user.
The order details of a particular order (like ProductID, Name,
Description, Quantity etc.) are displayed in one DataGrid where as the
personal details of the buyer corresponding to this order (like Name,
E-Mail, Shipping & Billing Address etc.) are displayed in another...
|
by: Jim |
last post by:
OK here's my disclaimer: I'm very new to ASP.NET and posting on Google
Groups, so please bear with me and feel free to correct either the way
I code or the way I post.
I have an ASP.NET page that is driven off of a dynamic dropdownlist
control. In the page_load sub, I make the DB connection and fill the
list based on a table of employees. Once an employee is selected,
there are various datagrids below that are populated based on that...
|
by: =?Utf-8?B?Sm9obiBXYWxrZXI=?= |
last post by:
Hi, I am using the code below to export a webpage to Excel. The webpage has
three datagrids on it and they are all exported to Excel properly and
everything looks very nice, but we would really only like two of the three
datagrids to be exported. Is there a way to exclude certain sections of the
webpage from being exported to Excel? "DG" in the code here is one of the
datagrids on the page:
...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |