Here's the code I have now. What's missing. Something simple?
<
html xmlns="http://www.w3.org/1999/xhtml" >
<
head runat="server">
<title>Address Page</title>
</
head>
<
body>
<form id="form1" runat="server">
<rad:RadAjaxManager ID="RadAjaxManager1" runat="server">
<AjaxSettings>
<rad:AjaxSetting AjaxControlID="RadGrid1">
<UpdatedControls>
<rad:AjaxUpdatedControl ControlID="RadGrid1" />
</UpdatedControls>
</rad:AjaxSetting>
</AjaxSettings>
</rad:RadAjaxManager>
<rad:RadGrid ID="RadGrid1"
runat="server" AutoGenerateColumns="False"
GridLines="None" Skin="FFCIGreen"
AllowPaging="True" AllowCustomPaging="True"
EnableAJAXLoadingTemplate="True"
PageSize="10" Width="100%" AllowAutomaticUpdates="true" AllowAutomaticInserts="true" AllowAutomaticDeletes="true"
OnNeedDataSource="RadGrid1_NeedDataSource"
OnEditCommand="RadGrid1_EditCommand"
OnInsertCommand="RadGrid1_InsertCommand"
OnPageIndexChanged="RadGrid1_PageIndexChanged">
<ClientSettings>
<Selecting AllowRowSelect="True"></Selecting>
</ClientSettings>
<AJAXLoadingTemplate>
<div >Loading....</div>
</AJAXLoadingTemplate>
<MasterTableView DataKeyNames="AddressID" AutoGenerateColumns="false" EditMode="EditForms">
<Columns>
<rad:GridButtonColumn Text="Select" CommandName="Select"></rad:GridButtonColumn>
<rad:GridEditCommandColumn UniqueName="EditCommandColumn" ButtonType="ImageButton"
HeaderText="Edit">
</rad:GridEditCommandColumn>
<rad:GridBoundColumn DataField="AddressID" DataType="System.Int32" HeaderText="AddressID"
ReadOnly="True" SortExpression="AddressID" UniqueName="AddressID">
</rad:GridBoundColumn>
<rad:GridBoundColumn DataField="StreetAddress" HeaderText="StreetAddress" SortExpression="StreetAddress"
UniqueName="StreetAddress">
</rad:GridBoundColumn>
<rad:GridBoundColumn DataField="City" HeaderText="City" SortExpression="City" UniqueName="City">
</rad:GridBoundColumn>
<rad:GridBoundColumn DataField="StateCD" HeaderText="StateCD" SortExpression="StateCD"
UniqueName="StateCD">
</rad:GridBoundColumn>
<rad:GridBoundColumn DataField="ZipCode" HeaderText="ZipCode" SortExpression="ZipCode"
UniqueName="ZipCode">
</rad:GridBoundColumn>
</Columns>
<RowIndicatorColumn Visible="True">
<HeaderStyle Width="20px" />
</RowIndicatorColumn>
<PagerStyle NextPageText="Next" PrevPageText="Prev" Mode="NextPrevAndNumeric" Position="Bottom" >
</PagerStyle>
<EditFormSettings EditFormType="Template">
<FormTemplate>
Demo mode
<table>
<tr>
<td align="right" colspan="2">
<asp:Button ID="btnUpdate" Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>'
runat="server" CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'>
</asp:Button>
<
asp:Button ID="btnCancel" Text="Cancel" runat="server" CausesValidation="False"
CommandName
="Cancel"></asp:Button></td>
</tr>
</table>
</FormTemplate>
</EditFormSettings>
</MasterTableView>
</rad:RadGrid>
</form>
</
body>
</
html>
using
System;
using
System.Data;
using
System.Configuration;
using
System.Collections;
using
System.Web;
using
System.Web.Security;
using
System.Web.UI;
using
System.Web.UI.WebControls;
using
System.Web.UI.WebControls.WebParts;
using
System.Web.UI.HtmlControls;
public
partial class Operations_Address : System.Web.UI.Page
{
protected int pageIndex; //for paging only
protected int pageSize = 10;
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
SetVirtualItemCount();
pageIndex = 1;
int addressID = -1;
if (!String.IsNullOrEmpty(Request.QueryString["AddressID"]))
{
Boolean validInt = Int32.TryParse(Request.QueryString["AddressID"].ToString(), out addressID);
if (validInt)
{
int[] selectedIndex = { addressID };
RadGrid1.SelectedIndexes.Add(selectedIndex);
}
}
}
}
//Get the count of records in the table and use the number to set the virtual count
//of each grid.
protected void SetVirtualItemCount()
{
try
{
object tempResult = DataUtilities.GetScalarValue("Select count(*) from Address");
int addressCount = -1;
if (int.TryParse(tempResult.ToString(),out addressCount))
{
RadGrid1.VirtualItemCount = addressCount;
}
}
catch (Exception e)
{
// I dunno.
}
}
protected void RadGrid1_PageIndexChanged(object source, Telerik.WebControls.GridPageChangedEventArgs e)
{
//db paging starts with 1, RadGrid starts with 0 so we add 1 to what ever page is being added.
pageIndex = e.NewPageIndex + 1;
// No need for a rgPaging.Rebind()
}
protected void RadGrid1_NeedDataSource(object source, Telerik.WebControls.GridNeedDataSourceEventArgs e)
{
RadGrid1.DataSource = getPagingData(pageIndex, pageSize);
}
protected DataTable getPagingData(int PageNumber, int PageSize)
{
String sqlStatement = "Select * from Address ";
sqlStatement +=
"WHERE AddressID between (" + PageNumber + "-1)*" + PageSize + " and (" + PageNumber + ")*" + PageSize;
return DataUtilities.GetDataTable(sqlStatement);
}
protected void RadGrid1_InsertCommand(object source, Telerik.WebControls.GridCommandEventArgs e)
{
}
protected void RadGrid1_EditCommand(object source, Telerik.WebControls.GridCommandEventArgs e)
{
String s = "test";
}
}