or
public void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e) { if (e.Item is GridDataItem && e.Item.OwnerTableView.Name == "Parent") { string linkValue = e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["NotesLink"].ToString(); HyperLink hl = new HyperLink(); string strFunctionToCall = "ViewCheck('" + linkValue + "')"; hl.Attributes.Add("onClick", "return " + strFunctionToCall + ";"); hl.ToolTip = "Click for more info...."; hl.Text = linkValue; hl.Font.Underline = true; hl.ForeColor = Color.Blue; GridDataItem item = (GridDataItem)e.Item; item["NotesLink"].Controls.Add(hl); }}protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e){if (e.CommandName == "ShowAbstractDetails" && e.Item.OwnerTableView.Name == "Parent"){ GridDataItem parentRow = e.Item as GridDataItem; parentRow.Selected = true; // Force the row to be selected if (parentRow.HasChildItems) // Ignore ChildRow clicks { // Expand selected item int temp = RadGrid1.SelectedItems.Count; foreach (GridDataItem item in RadGrid1.SelectedItems) { if (item.Selected) { item.Expanded = true; } else { item.Expanded = false; } } }}<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Edit_GovernanceContacts.aspx.vb" Inherits="APSubmission.Edit_GovernanceContacts" %><%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %><%@ Register TagPrefix="uc1" TagName="Menu" Src="Menu.ascx" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head id="Head1" runat="server"> <title>Submission System</title></head><body style="background-color: #f2ffff"> <form id="form1" runat="server"> <telerik:RadScriptManager ID="RadScriptManager1" runat="server"> </telerik:RadScriptManager> <div> <uc1:Menu ID="Menu1" runat="server"></uc1:Menu> </div> <div style="padding: 10px 0 0 10px"> Edit Governance Contacts <telerik:RadGrid ID="gridContacts" runat="server" AllowAutomaticDeletes="True" EnableAJAX="True" AllowAutomaticInserts="True" AllowAutomaticUpdates="True" Skin="WebBlue"> <MasterTableView AutoGenerateColumns="False" DataKeyNames="recID" CommandItemDisplay="TopAndBottom"> <EditFormSettings> <EditColumn UniqueName="EditCommandColumn"></EditColumn> </EditFormSettings> <Columns> <telerik:GridEditCommandColumn UniqueName="EditCommandColumn" ButtonType="imagebutton" /> <telerik:GridBoundColumn DataField="recID" FilterControlAltText="Filter columnID column" HeaderText="ID" UniqueName="recID"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="submissionSetID" FilterControlAltText="Filter columnSubmissionSet column" HeaderText="Submission Set ID" UniqueName="submissionSetID"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="contactName" FilterControlAltText="Filter columnContactName column" HeaderText="Contact Name" UniqueName="contactName"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="addDate" DataType="System.DateTime" FilterControlAltText="Filter columnAddDate column" HeaderText="Add Date" ReadOnly="True" UniqueName="addDate"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="addWho" FilterControlAltText="Filter columnAddWho column" HeaderText="Add Who" ReadOnly="True" UniqueName="addWho"> </telerik:GridBoundColumn> <telerik:GridButtonColumn UniqueName="ButtonColumn" Text="Delete" CommandName="Delete" ButtonType="LinkButton"/> </Columns> </MasterTableView> </telerik:RadGrid> </div> </form></body></html>Protected Sub gridContacts_NeedDataSource(sender As Object, e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles gridContacts.NeedDataSource Dim myDataSource As New SqlDataSource myDataSource.ConnectionString = _functions.GetConnectionString() myDataSource.DeleteCommand = "delete GovernanceContact where recID = @recID" myDataSource.InsertCommand = "insert GovernanceContact (submissionSetID, contactName, addDate, addWho) values @submissionSetID, @contactName, @addDate, @addWho)" myDataSource.SelectCommand = "select * from GovernanceContact where submissionSetID = @submissionSetID" myDataSource.UpdateCommand = "update GovernanceContact set contactName = @contactName where recID = @recID" myDataSource.DeleteParameters.Add("recID", DbType.Int32) myDataSource.InsertParameters.Add("submissionSetID", DbType.Int32, _editSubmissionSetID) myDataSource.InsertParameters.Add("contactName", DbType.String) myDataSource.InsertParameters.Add("addDate", DbType.DateTime) myDataSource.InsertParameters.Add("addWho", DbType.String) myDataSource.SelectParameters.Add("submissionSetID", DbType.Int32, _editSubmissionSetID) myDataSource.UpdateParameters.Add("contactName", DbType.String) myDataSource.UpdateParameters.Add("recID", DbType.Int32) gridContacts.DataSource = myDataSource gridContacts.MasterTableView.DataSource = myDataSource End Sub
Hi,
I have an implementation question which I'm hoping someone with much more experience and expertise could guide me in the right direction.
I need to load a batch of 5000 ~ 10,000 phone numbers into a database.
The user can select and upload a file using RadUpload and RadGrid with Paging turned on.
The user can preview, add, delete the record in the RadGrid and then click on 'Insert' button to load the phone numbers into database.
I'm really hoping to cache the data instead of using a saved file on the server for re-binding.
I think RadGrid only holds data for the current page, so what would be the best way to implement this?
Thank you in advance~
Helen
protected void Page_Load(object sender, EventArgs e){ this.tollFreeInventoryLogic = (TollFreeInventoryLogic)this.Session[SESSION_ATTR_NAME]; if (tollFreeInventoryLogic == null) { this.tollFreeInventoryLogic = new TollFreeInventoryLogic(); this.Session[SESSION_ATTR_NAME] = this.tollFreeInventoryLogic; }}protected void RadButtonUploadToGrid_Click(object sender, EventArgs e){ string targetFolder = RadUpload1.AppRelativeTemplateSourceDirectory + RadUpload1.TargetFolder; string fileName = targetFolder + "/" + RadUpload1.UploadedFiles[0].GetName(); Session["fileName"] = fileName; GetDataFromMemory();}protected void GetDataFromFile(){ if (Session["fileName"] != null) { string fileName = (string)Session["fileName"]; try { using (StreamReader sr = new StreamReader(Server.MapPath(fileName))) { string tollFreeList = sr.ReadToEnd(); string[] tollFreeArray = tollFreeList.Split(new string[] { System.Environment.NewLine }, StringSplitOptions.None); DataTable dt = CreateDataTable(tollFreeArray); RadGrid1.DataSource = dt; } } catch (Exception err) { Console.WriteLine("The file could not be read:"); Console.WriteLine(err.Message); } }}protected void GetDataFromMemory(){ foreach (UploadedFile file in RadUpload1.UploadedFiles) { byte[] bytes = new byte[file.ContentLength]; file.InputStream.Read(bytes, 0, bytes.Length); string tollFreeList = System.Text.Encoding.Default.GetString(bytes); string[] tollFreeArray = tollFreeList.Split(new string[] { System.Environment.NewLine }, StringSplitOptions.None); DataTable dt = CreateDataTable(tollFreeArray); RadGrid1.DataSource = dt; RadGrid1.DataBind(); } }private DataTable CreateDataTable(string[] tollFreeArray){ DataTable dt = new DataTable(); DataRow dr; dt.Columns.Add("TollFreeNumber"); foreach (string line in tollFreeArray) { //Debug.WriteLine(line); if (line.Trim().Length > 0) { dr = dt.NewRow(); dr["TollFreeNumber"] = line; dt.Rows.Add(dr); } } return dt;}protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e){ GetDataFromFile();}
function openRadWindow(url, title, width, height) { var oManager = GetRadWindowManager(); oWnd = oManager.open(url, null); oWnd.set_title(title); oWnd.setSize(width, height); oWnd.center();