Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 4 > ASP.NET 4 General Discussion
|
ASP.NET 4 General Discussion For ASP.NET 4 discussions not relating to a specific Wrox book
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 4 General Discussion section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 10th, 2013, 07:15 AM
Registered User
 
Join Date: Sep 2012
Posts: 9
Thanks: 3
Thanked 0 Times in 0 Posts
Default Load Repeater (Data)content on click event?

I have a Repeater control and there is a gridview inside this repeater and when users adds comment i want to populate the gridview and display the newly added comment instantly, how could i do this? I use exact the same structure on the book as LINQ anonymous type. Any idea or help will be appreciated. Thanks!

Last edited by master777; April 10th, 2013 at 10:16 AM..
 
Old April 10th, 2013, 07:31 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

The error is on line 17....

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old April 10th, 2013, 07:55 PM
Registered User
 
Join Date: Sep 2012
Posts: 9
Thanks: 3
Thanked 0 Times in 0 Posts
Default Sorry!

I like to remove this thread if possible?
 
Old April 11th, 2013, 03:05 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Did you figure it out? As I suggested in my other post, it's impossible to help if you don't post the relevant bits of code.....

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old April 11th, 2013, 07:52 AM
Registered User
 
Join Date: Sep 2012
Posts: 9
Thanks: 3
Thanked 0 Times in 0 Posts
Default Sure!

Hi, I thought you already know what i am using because the structure and the idea is identical actually(yours), just swap the Genre with as "Event" and comments remains the same hence i created a "Add Event" function form that you can add an event(genre) and add your comments right beneath the particular event. Would you like to see the repeater code? it's slightly different! I use a table to display events items and i use GridView to display comments. I also use DetailsView to obtain the comments but this is out of the Repeater. All I am trying to achieve is to have gridView populate exactly when the new comment is added and display it shortly after a "Add Comment" Button Click Event is fired. Which it didn't work!

Here is the example of my code;

MarkUp Code:

<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional" OnLoad="UpdatePanel1_Load"
OnPreRender="UpdatePanel1_PreRender" ChildrenAsTriggers="true">

<ContentTemplate>
<asp:Repeater ID="Repeater1" runat="server" OnItemDataBound="Repeater1_ItemDataBound"
OnItemCommand="RepeaterGetSelectedID">
<HeaderTemplate>
<br />
<center>
<h1 style="color: Gray; font-size: 18pt;">
Local Events</h1>
</center>
<div id="NoRecords" runat="server" visible="false" style="text-align: center;">
<asp:Label ID="Label9" runat="server" Text="No current events are available." CssClass="ErrorMessage"
Font-Italic="True" Font-Bold="True" Font-Size="Large"></asp:Label>
</div>
</HeaderTemplate>
<ItemTemplate>
<div class="EventsComments">
<div id="divDisplay">
<table class="style1" align="left" id="tblEventsArea">
<tr>
<td rowspan="8" align="left" class="style3" width="150">
<asp:HiddenField ID="HiddenID" runat="server" Value='<%# Eval("Id") %>' />
<img id="Img1" alt="All Stars Cyprus Event Photo JPG" src="/Images/NoPhotoAvailable.jpg"
runat="server" style="max-height: 255px; max-width: 255px;" class="Image3" />
</td>
<td class="style5" width="10">
&nbsp;
</td>
<td class="style5" width="120" nowrap="nowrap">
Venue Name:
</td>
<td class="style1" width="510px">
<asp:Label ID="lblVenueName" runat="server" Text='<%# Eval("VenueName") %>' Style="font-weight: 700;
color: #993333; font-size: 20px"></asp:Label>
</td>
</tr>
<tr>
<td class="style3" width="10">
</td>
<td class="style3" width="120" nowrap="nowrap">
Event Type:
</td>
<td class="style4" width="510px">
<asp:Label ID="Label2" runat="server" Text='<%# Eval("EventType") %>' Style="color: #000066;
font-weight: 700"></asp:Label>
</td>
</tr>
<tr>
<td class="style5" width="10">
&nbsp;
</td>
<td class="style5" width="120" nowrap="nowrap">
Event Date:
</td>
<td class="style1" width="510px">
<asp:Label ID="Label3" runat="server" Text='<%# Eval("Date") %>'
Style="font-weight: 700; font-size: 15px; color: #FF3300"></asp:Label>
</td>
</tr>
<tr>
<td class="style5" width="10">
&nbsp;
</td>
<td class="style5" width="120" nowrap="nowrap">
Starting Time:
</td>
<td class="style1" width="510px">
<asp:Label ID="Label4" runat="server" Text='<%# Eval("StartTime") %>'
Style="font-weight: 700; font-size: 15px; color: #000000"></asp:Label>
</td>
</tr>
<tr>
<td class="style5" width="10">
&nbsp;
</td>
<td class="style5" width="120" nowrap="nowrap">
Ending Time:
</td>
<td class="style1" width="510px">
<asp:Label ID="Label5" runat="server" Text='<%# Eval("EndTime") %>'
Style="font-weight: 700; font-size: 15px; color: #000000"></asp:Label>
</td>
</tr>
<tr>
<td class="style5" width="10">
&nbsp;
</td>
<td class="style5" width="120" nowrap="nowrap">
Contact Phone:
</td>
<td class="style1" width="510px">
<asp:Label ID="Label6" runat="server" Text='<%# Eval("Phone") %>' Style="color: #FF3300;
font-size: 15px; font-weight: 700"></asp:Label>
</td>
</tr>
<tr>
<td class="style5" valign="top" width="10">
&nbsp;
</td>
<td class="style5" valign="top" width="120" nowrap="nowrap">
Address:
</td>
<td class="style1" valign="top" width="510px">
<asp:Label ID="Label7" runat="server" Text='<%# Eval("Address") %>' Style="color: #333333;
font-size: 15px; font-weight: 700"></asp:Label>
</td>
</tr>
<tr>
<td class="style5" valign="top" width="10">
&nbsp;
</td>
<td class="style5" valign="top" width="120">
&nbsp;
</td>
<td align="right" class="style1" valign="top" width="510px">

<br />
<asp:LinkButton ID="lnkSelect" CommandName="Select" runat="server" OnClick="lnkSelect_Click"
Font-Italic="True" ToolTip="Post your comment for this event." CssClass="addComment"> Add your comment here!</asp:LinkButton>&nbsp;
</td>
</tr>
</table>
</div>

</div>
<br />
<div id="reviews">
<asp:GridView ID="GridView1" runat="server" DataSource='<%# Eval("Reviews") %>' AutoGenerateColumns="False"
BackColor="#FFFFE6" Font-Size="Medium" BorderStyle="Solid" CellSpacing="1" CellPadding="10"
ForeColor="#333333" AlternatingRowStyle-BackColor="#CCCCCC" Width="811px" CssClass="grid">
<AlternatingRowStyle BackColor="#EEFFFE"></AlternatingRowStyle>
<Columns>
<asp:BoundField HeaderText="Commented By" DataField='NickName' ItemStyle-Wrap="False"
ItemStyle-Height="25" ItemStyle-Width="150">
<HeaderStyle HorizontalAlign="Center" />
<ItemStyle Wrap="False" Height="25px" Width="150px" HorizontalAlign="Center" Font-Bold="True"
ForeColor="#0000CC"></ItemStyle>
</asp:BoundField>
<asp:BoundField HeaderText="Comment" DataField="Comment">
<HeaderStyle HorizontalAlign="Center" />
<ItemStyle ForeColor="Maroon" Font-Bold="false" />
</asp:BoundField>
<asp:TemplateField HeaderText="Date &amp;Time Created">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("CreateDateTime") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="lblCreateDateTime" runat="server" Text='<%# Eval("CreateDateTime") %>'
ForeColor="#666666"></asp:Label>
</ItemTemplate>
<HeaderStyle HorizontalAlign="Center" />
<ItemStyle HorizontalAlign="Center" Width="180px" />
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
<br />
<br />
</ItemTemplate>
</asp:Repeater>
</ContentTemplate>
</asp:UpdatePanel>

<DetailsView here that is used to insert comments />

CodeBehind for my Linq DataSource as;

var allEvents = from a in myEntities.AddEvents

where a.Authorized == true
where a.Date >= today
orderby a.Id descending
select new
{
a.Id,
a.VenueName,
a.EventType,
a.Date,
a.StartTime,
a.EndTime,
a.Address,
a.Phone,
a.Reviews
};
Repeater1.DataSource = allEvents;
Repeater1.DataBind();

I hope this would give you a sufficient idea which i am sure of that. Any help or idea will be appreciated, thanks!

P.S please let me know if i omitted anything above.

Last edited by master777; April 11th, 2013 at 08:03 AM..
 
Old April 11th, 2013, 11:13 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Have you tried calling DataBind on the control that displays the comments at the end of the Click handler for the Add Comment button?

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old April 11th, 2013, 01:18 PM
Registered User
 
Join Date: Sep 2012
Posts: 9
Thanks: 3
Thanked 0 Times in 0 Posts
Default Sure!

Hi, Honestly i have tried various stuff, i.e. tried populating the whole LINQ data expression in the click event so i could have my GridView populated, or updatePnl.update() which i couldn't make this working at all! either on the click nor pageLoad, init. onLoad, preRender etc. Thus i don't know what we have it's method for? I also tried to (postBack)refresh the page to cause dataGrid populate and display newly added(inserted) record on the click event and pageLoad but no! no! no!. Since i am new and started like last year by collecting and building my programming library where consist of the physical books, so i can hardly say that i am experienced enough to know about these things. In fact this is my very first try on many things right from databases to collect values dynamically so on and so forth. I have been searching though the internet for over a week but can't find anything about it. I am really frustrated! and overwhelmed. just need a help here.

I think i know what you mean! it's like this:
GridView1.DataBind();

I don't know how to use this! because i am new on SQL and i have not much ideas especially in a scenario like yours! It confuses me a lot because you use Review entity as a data item. It's kind of advanced and i have no idea ultimately! Could you please give me a tip please? Thank you!!!
 
Old April 11th, 2013, 01:22 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

>> I don't know how to use this!

Exactly as you showed, from the button's click event handler.

I see that the GridView is inside the Repeater, so maybe you need to rebind the data to the Repeater and call DataBind, similar to how you bind it on the initial load?

Alternatively, you could redirect to the same.

Cheers,
Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old April 11th, 2013, 08:21 PM
Registered User
 
Join Date: Sep 2012
Posts: 9
Thanks: 3
Thanked 0 Times in 0 Posts
Default Finally

Hi, I have finally managed to achieve this by using the itemInserted event handler so it wasn't the click event all along. Sweet Jesus! Yey! I have to thank you for helping me by writing and publishing this book and also helping each of us individually via your site! Thank you! God Bless you! :)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Load Repeater (Data)content on page load? master777 BOOK: Beginning ASP.NET 4 : in C# and VB 1 April 10th, 2013 02:32 AM
Firing 1 usercontrol used for 3 different window at page load with different data Burledivya .NET Framework 3.5 0 February 1st, 2010 10:53 AM
Page won't load data in IE rinventive PHP How-To 8 June 23rd, 2006 10:03 PM
Dynamic content in Load Balancing Envoirnment deadman BOOK: Professional Apache Tomcat 0 November 17th, 2004 03:30 AM
How to split pages when content load dynamically bekim Classic ASP Basics 0 August 5th, 2004 02:57 AM





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