ASP Ajax Update Panel

5 views
Skip to first unread message

AdonisL81

unread,
Apr 13, 2008, 11:32:07 AM4/13/08
to DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting
Hello,
I am new to .NET I am having trouble with a asp update panel
and Gridview.

The Gridview control is inside the update panel and I am trying to
have the gridview update from a form button. The form updates the
database from which the gridview pulls data.

The panel and gridview works if I do a postback from within the
gridview such as sorting. but I can not get it to work from the
button. here is my code.

I'm sure I missed something but if anyone can help that would be
appreciated

<%@ Page Language="VB" AutoEventWireup="true"
CodeFile="Default.aspx.vb" Inherits="_Default" %>
<%@ Register Assembly="AjaxControlToolkit"
Namespace="AjaxControlToolkit" TagPrefix="cc1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/
TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Untitled Page</title>
<link href="StyleSheet.css" rel="stylesheet" type="text/css" />
</head>
<body>

<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<div>
</div>




<div id="wrapper">
<div id="input">


<label >Department:</label>
<asp:DropDownList ID="DropDownList1" runat="server">
<asp:ListItem></asp:ListItem>
<asp:ListItem>ADMN</asp:ListItem>
<asp:ListItem>OTHER</asp:ListItem>
<asp:ListItem>TEST</asp:ListItem>
</asp:DropDownList>
<br />
<br />
<label >Type of Hours:</label>

<asp:DropDownList ID="DropDownList2" runat="server"
Height="16px" Width="42px" >
<asp:ListItem></asp:ListItem>
<asp:ListItem>1</asp:ListItem>
<asp:ListItem>2</asp:ListItem>
<asp:ListItem>3</asp:ListItem>
<asp:ListItem>4</asp:ListItem>
</asp:DropDownList>
<br />
<br />
<label>Hours:</label>
<asp:TextBox ID="TextBox1"
runat="server" Width="50px"></asp:TextBox>
<br />
<br />
<label>Date:</label><asp:TextBox ID="TextBox3" runat="server"></
asp:TextBox>
<cc1:CalendarExtender ID="CalendarExtender1" runat="server"
Format="M/d/yyyy"
TargetControlID="textbox3">
</cc1:CalendarExtender>

<asp:RangeValidator ID="RangeValidator1" runat="server"
ControlToValidate="TextBox3" ErrorMessage="RangeValidator"
Type="Date"></asp:RangeValidator>

<br />
<label>Job Number:</label>
<asp:DropDownList ID="DropDownList3" runat="server"
AutoPostBack="True">
<asp:ListItem></asp:ListItem>
<asp:ListItem>1234</asp:ListItem>
<asp:ListItem>1234</asp:ListItem>
<asp:ListItem>5678</asp:ListItem>
<asp:ListItem>7896</asp:ListItem>
<asp:ListItem>1236</asp:ListItem>
</asp:DropDownList>
<br />
<br />
<label>Phase:</label>
<asp:DropDownList ID="DropDownList4" runat="server"
AutoPostBack="True">
<asp:ListItem>MISC</asp:ListItem>
<asp:ListItem>ADMN</asp:ListItem>
<asp:ListItem>TEST</asp:ListItem>
<asp:ListItem>Other</asp:ListItem>
</asp:DropDownList>
<br />
<br />
<label>Category:</label>
<asp:DropDownList ID="DropDownList5" runat="server"
AutoPostBack="True">
<asp:ListItem>TEST</asp:ListItem>
<asp:ListItem>NEXT</asp:ListItem>
<asp:ListItem>ONE</asp:ListItem>
<asp:ListItem>LAST</asp:ListItem>
</asp:DropDownList>
<br />
<br />
<label>Description:</label>
<asp:TextBox ID="TextBox2"
runat="server" Height="150px" Width="200px"></asp:TextBox>
<br />

<br />
<asp:Button ID="Button1" runat="server" Text="Add Time"
style="height: 26px"/>
</div>


<asp:UpdatePanel ID="UpdatePanel1" runat="server" >
<ContentTemplate>

<asp:GridView ID="GridView1" runat="server"
AllowPaging="True"
AllowSorting="True" DataSourceID="GetUserTime"
AutoGenerateColumns="False" DataKeyNames="id" >
<Columns>
<asp:CommandField ShowDeleteButton="True"
ShowEditButton="True" />
<asp:BoundField DataField="Initials"
HeaderText="Initials"
SortExpression="Initials" />
<asp:BoundField DataField="Dept" HeaderText="Dept"
SortExpression="Dept" />
<asp:BoundField DataField="HourType"
HeaderText="HourType"
SortExpression="HourType" />
<asp:BoundField DataField="Hours" HeaderText="Hours"
SortExpression="Hours" />
<asp:BoundField DataField="Date" HeaderText="Date"
SortExpression="Date" />
<asp:BoundField DataField="Job#" HeaderText="Job#"
SortExpression="Job#" />
<asp:BoundField DataField="Phase" HeaderText="Phase"
SortExpression="Phase" />
<asp:BoundField DataField="Category"
HeaderText="Category"
SortExpression="Category" />
<asp:BoundField DataField="Description"
HeaderText="Description"
SortExpression="Description" />
</Columns>
</asp:GridView>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Button1"
EventName="Click"/>
</Triggers>
</asp:UpdatePanel>

Andrew Badera

unread,
Apr 14, 2008, 12:44:40 PM4/14/08
to DotNetDe...@googlegroups.com
Yep, you probably missed something.

Nope, I'm not sorting through your ugly lump of code to find it.

Learn how to debug. Learn how to present questions. Then get back to us. Feel free to check out the multitudinous videos and howtos on this subject through channel9 and other such sources in the meantime.
--
--Andy Badera
http://andrew.badera.us/ http://flipbitsnotburgers.blogspot.com/
and...@badera.us
(518) 641-1280
Google me: http://www.google.com/search?q=andrew+badera

CK

unread,
Apr 14, 2008, 1:32:25 PM4/14/08
to DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting
An easy, nasty way to do it is have a hidden button inside the
updatepanel, then have your button outside the panel simulate a click
on the hidden button.

The hard part is writing Javascript to do that.... Good luck :)

AdonisL81

unread,
Apr 14, 2008, 3:40:53 PM4/14/08
to DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting
Well that is my issue, I have went through tutorials and videos, I
have added another update panel which updates the time and that seems
to work but the update panel with grid view does not work. I wouldn't
ask for anyone to sort through my "ugly lump of code" if I didn't
research for my self first. I am just wondering if anyone has
experienced this.

Thanks

On Apr 14, 11:44 am, "Andrew Badera" <and...@badera.us> wrote:
> Yep, you probably missed something.
>
> Nope, I'm not sorting through your ugly lump of code to find it.
>
> Learn how to debug. Learn how to present questions. Then get back to us.
> Feel free to check out the multitudinous videos and howtos on this subject
> through channel9 and other such sources in the meantime.
>
>
>
> On Sun, Apr 13, 2008 at 11:32 AM, AdonisL81 <Adonis...@gmail.com> wrote:
>
> > Hello,
> > I am new to .NET I am having trouble with a asp update panel
> > and Gridview.
>
> > The Gridview control is inside the update panel and I am trying to
> > have the gridview update from a form button. The form updates the
> > database from which the gridview pulls data.
>
> > The panel and gridview works if I do a postback from within the
> > gridview such as sorting. but I can not get it to work from the
> > button. here is my code.
>
> > I'm sure I missed something but if anyone can help that would be
> > appreciated
>
> > <%@ Page Language="VB" AutoEventWireup="true"
> > CodeFile="Default.aspx.vb" Inherits="_Default" %>
> > <%@ Register Assembly="AjaxControlToolkit"
> > Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
>
> > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/
> > TR/xhtml11/DTD/xhtml11.dtd <http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd>
> --Andy Baderahttp://andrew.badera.us/http://flipbitsnotburgers.blogspot.com/

Andrew Badera

unread,
Apr 15, 2008, 1:25:53 PM4/15/08
to DotNetDe...@googlegroups.com
If you used, as this list constantly advises, http://pastebin.com/ you'd be a lot less likely to get this sort of response.

If you don't present your question in a reasonable fashion, when the means are there, then you can't expect much reasonable response.

AdonisL81

unread,
Apr 15, 2008, 3:17:14 PM4/15/08
to DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting
Thanks

On Apr 15, 12:25 pm, "Andrew Badera" <and...@badera.us> wrote:
> If you used, as this list constantly advises,http://pastebin.com/you'd be
> a lot less likely to get this sort of response.
>
> If you don't present your question in a reasonable fashion, when the means
> are there, then you can't expect much reasonable response.
>

Jim Losi

unread,
Apr 16, 2008, 8:45:42 AM4/16/08
to DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting
if you have logic in the buttons' click event handler that updates the
gridviews' data, then you'll need to do 3 things.
1. Set the updatemode on the update panel to conditional
2. re-bind the gridview
2. Call the update() method on the updatepanel after you call
DataBind() on the gridview.

This will force the updatepanel to refresh the gridviews' view.
Reply all
Reply to author
Forward
0 new messages