ASP Ajax Update Panel


A

AdonisL81

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>
 
Ad

Advertisements


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