or
<script type="text/javascript"> function OnClientFileSelected(sender, args) { alert(args.get_fileName()); }</script> <telerik:RadGrid ID="RadGrid1" runat="server" CellSpacing="0" Culture="it-IT" GridLines="None" DataKeyNames="ID A" DataSourceID="SqlDataSource1" AutoGenerateColumns="false" Width="1000px" AllowSorting="true" GroupingSettings-CaseSensitive="false" EnableLinqExpressions="false" AllowPaging="true" PageSize="20" OnItemDataBound="RadGrid1_ItemDataBound" OnInsertCommand="RadGrid1_InsertCommand" OnUpdateCommand="RadGrid1_UpdateCommand"> <MasterTableView DataKeyNames="ID Albo" DataSourceID="SqlDataSource1" CommandItemDisplay="TopAndBottom"> <Columns> <telerik:GridEditCommandColumn UniqueName="EditCommandColumn" EditText="Modifica" UpdateText="Aggiorna" InsertText="Inserisci" CancelText="Annulla"> </telerik:GridEditCommandColumn> <telerik:GridBoundColumn HeaderText="Categoria" DataField="Descrizione" UniqueName="Descrizione"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="Ultima Modifica" HeaderText="Ultima Modifica" UniqueName="Ultima_Modifica"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="Oggetto" HeaderText="Oggetto" UniqueName="Oggetto"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="Valido Dal" HeaderText="Valido Dal" UniqueName="Valido_Dal" DataFormatString="{0:dd/MM/yyyy}" > </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="Valido Al" HeaderText="Valido Al" UniqueName="Valido_Al" DataFormatString="{0:dd/MM/yyyy}"> </telerik:GridBoundColumn> </Columns> <EditFormSettings EditFormType="Template"> <FormTemplate> <div style="margin-left:15px;"> <div style="height:10px"></div><telerik:RadAsyncUpload ID="rupDocumento" runat="server" MaxFileSize="11048576" MaxFileInputsCount="1" Localization-Select="Seleziona" Localization-Cancel="Cancella" Localization-Remove="Rimuovi" AllowedFileExtensions="pdf" OnClientFileSelected="OnClientFileSelected" ></telerik:RadAsyncUpload> <div style="height:10px"></div> <div style="height:10px"></div> <asp:DropDownList ID="DDLCategoria" runat="server" DataTextField="Descrizione" DataValueField="ID Tipo Categoria Albo"></asp:DropDownList> <div style="height:10px"></div> <asp:TextBox ID="txtOggetto" runat="server" MaxLength="255" Text='<%#Eval("Oggetto")%>' Width="400"></asp:TextBox> <div style="height:10px"></div> Validità<br /> Dal <%=DateTime.Now.ToString("dd/MM/yyyy")%><br /> <asp:RadioButton ID="rbNoScad" runat="server" Text="Senza Scadenza" GroupName="Scadenza" /><br /> <asp:RadioButton ID="rb15Scad" runat="server" Text="15 giorni" GroupName="Scadenza" /><br /> <asp:RadioButton ID="rb30Scad" runat="server" Text="30 giorni" GroupName="Scadenza" /><br /> <asp:RadioButton ID="rb60Scad" runat="server" Text="60 giorni" GroupName="Scadenza" /><br /> <asp:RadioButton ID="rbFinoAlScad" runat="server" Text="valido fino al" CssClass="sAlign" GroupName="Scadenza" /> <telerik:RadDatePicker ID="rdpAl" runat="server" CssClass="sAlign2"></telerik:RadDatePicker><br /> <telerik:RadDatePicker ID="rdpDal" runat="server" Visible="false"></telerik:RadDatePicker> </div> <div style="height:10px"></div> <div style="text-align:center;"> <asp:Button ID="btnUpdate" Text='<%# (Container is GridEditFormInsertItem) ? "Inserisci" : "Aggiorna" %>' runat="server" CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>' ></asp:Button> <asp:Button ID="btnCancel" Text="Annulla" runat="server" CausesValidation="False" CommandName="Cancel" ></asp:Button> </div> <div style="height:10px"></div> <telerik:RadInputManager ID="RadInputManager1" runat="server"> </telerik:TextBoxSetting> <telerik:TextBoxSetting BehaviorID="RagExpBehavior2" Validation-IsRequired="true" ErrorMessage="Inserire l'oggetto" EmptyMessage="Oggetto"> <TargetControls> <telerik:TargetInput ControlID="txtOggetto"></telerik:TargetInput> </TargetControls> </telerik:TextBoxSetting> </telerik:RadInputManager> </FormTemplate> </EditFormSettings> <SortExpressions> <telerik:GridSortExpression FieldName="ID A" SortOrder="Descending" /> </SortExpressions> </MasterTableView> </telerik:RadGrid> <telerik:RadWindowManager ID="RadWindowManager1" runat="server" EnableShadow="true" KeepInScreenBounds="true"></telerik:RadWindowManager> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ProviderName="System.Data.SqlClient" ConnectionString="<%$ ConnectionStrings:StrConnection %>" SelectCommand = "SELECT [ID A], [Descrizione], [tStamp], [Oggetto], [Documento], [Cod Categoria], [Ultima Modifica], [Valido Dal], [Valido Al] FROM [Vista_Admin_Albo]"> </asp:SqlDataSource>
<EditFormSettings EditFormType="Template"> <FormTemplate> ??? combo bound to datafield from grid???? </FormTemplate> </EditFormSettings>//$(function () { // var meetingDataSource = new kendo.data.DataSource({ data: [ { MeetingId: 65, Year: 2014, MeetingDate: '2014-05-14 18:00:00', Title: "30 tools for modern .net web development in 60 minutes" }, { MeetingId: 64, Year: 2014, MeetingDate: '2014-04-09 18:00:00', Title: "azure websites deep dive" }, { MeetingId: 63, Year: 2014, MeetingDate: '2014-03-12 18:00:00', Title: "cancelled" }, { MeetingId: 62, Year: 2014, MeetingDate: '2014-02-12 18:00:00', Title: "getting to know windows azure mobile services" }, { MeetingId: 60, Year: 2013, MeetingDate: '2013-12-11 18:00:00', Title: "custom graphics for your web application: the html5 canvas and kinetic.js" }, { MeetingId: 59, Year: 2013, MeetingDate: '2013-11-13 18:00:00', Title: "four platforms. one codebase. xamarin." }, { MeetingId: 58, Year: 2013, MeetingDate: '2013-10-09 18:00:00', Title: "it’s cheaper than therapy: building an “eliza” psychotherapist app in windows 8" }, { MeetingId: 57, Year: 2013, MeetingDate: '2013-09-11 18:00:00', Title: "if typescript is the answer, what is the question?" } ] }); // meetingDataSource.fetch(function () { // var meetings = meetingDataSource.data(); // var years = _.chain(meetings) .pluck('Year') .uniq() .value(); // var shapedData = _.reduce(years, function (memo, year) { var exp = false; if (memo.length == 0) exp = true; // var det = _.chain(meetings) .filter(function (meeting) { return meeting.Year == year; }) .map(function (meeting) { var m = meeting; return { value: m.MeetingId, text: m.Title }; }) .value(); memo.push({ value: year, text: year, expanded: exp, items: det }); return memo; }, []); // $("#inline-listview").kendoPanelBar({ dataSource: shapedData, expandMode: "single" }).data("kendoPanelBar"); }); //});private static DataTable GetDataTable(string queryString) { String connString = ConfigurationManager.ConnectionStrings["NORTHWNDConnectionString"].ConnectionString; SqlConnection mySqlConnection = new SqlConnection(connString); SqlDataAdapter mySqlDataAdapter = new SqlDataAdapter(); mySqlDataAdapter.SelectCommand = new SqlCommand(queryString, mySqlConnection); DataTable myDataTable = new DataTable(); mySqlConnection.Open(); try { mySqlDataAdapter.Fill(myDataTable); } finally { mySqlConnection.Close(); } return myDataTable; } private DataTable Employees { get { object obj = this.Session["Employees"]; if ((!(obj == null))) { return ((DataTable)(obj)); } DataTable myDataTable = new DataTable(); myDataTable = GetDataTable("SELECT * FROM Employees"); this.Session["Employees"] = myDataTable; return myDataTable; } } protected void RadGrid1_NeedDataSource(object source, GridNeedDataSourceEventArgs e) { this.RadGrid1.DataSource = this.Employees; this.Employees.PrimaryKey = new DataColumn[] { this.Employees.Columns["EmployeeID"] }; } protected void RadGrid1_UpdateCommand(object source, GridCommandEventArgs e) { GridEditableItem editedItem = e.Item as GridEditableItem; UserControl userControl = (UserControl)e.Item.FindControl(GridEditFormItem.EditFormUserControlID); //Prepare new row to add it in the DataSource DataRow[] changedRows = this.Employees.Select("EmployeeID = " + editedItem.OwnerTableView.DataKeyValues[editedItem.ItemIndex]["EmployeeID"]); if (changedRows.Length != 1) { RadGrid1.Controls.Add(new LiteralControl("Unable to locate the Employee for updating.")); e.Canceled = true; return; } //Update new values Hashtable newValues = new Hashtable(); newValues["Country"] = (userControl.FindControl("TextBox7") as TextBox).Text; newValues["City"] = (userControl.FindControl("TextBox8") as TextBox).Text; newValues["Region"] = (userControl.FindControl("TextBox9") as TextBox).Text; newValues["HomePhone"] = (userControl.FindControl("HomePhoneBox") as RadMaskedTextBox).Text; newValues["BirthDate"] = (userControl.FindControl("BirthDatePicker") as RadDatePicker).SelectedDate.ToString(); newValues["TitleOfCourtesy"] = (userControl.FindControl("ddlTOC") as DropDownList).SelectedItem.Value; newValues["Notes"] = (userControl.FindControl("TextBox1") as TextBox).Text; newValues["Address"] = (userControl.FindControl("TextBox6") as TextBox).Text; newValues["FirstName"] = (userControl.FindControl("TextBox2") as TextBox).Text; newValues["LastName"] = (userControl.FindControl("TextBox3") as TextBox).Text; newValues["HireDate"] = (userControl.FindControl("HireDatePicker") as RadDatePicker).SelectedDate.ToString(); newValues["Title"] = (userControl.FindControl("TextBox4") as TextBox).Text; changedRows[0].BeginEdit(); try { foreach (DictionaryEntry entry in newValues) { changedRows[0][(string)entry.Key] = entry.Value; } changedRows[0].EndEdit(); this.Employees.AcceptChanges(); } catch (Exception ex) { changedRows[0].CancelEdit(); Label lblError = new Label(); lblError.Text = "Unable to update Employees. Reason: " + ex.Message; lblError.ForeColor = System.Drawing.Color.Red; RadGrid1.Controls.Add(lblError); e.Canceled = true; } } protected void RadGrid1_InsertCommand(object source, GridCommandEventArgs e) { UserControl userControl = (UserControl)e.Item.FindControl(GridEditFormItem.EditFormUserControlID); //Create new row in the DataSource DataRow newRow = this.Employees.NewRow(); //Insert new values Hashtable newValues = new Hashtable(); newValues["Country"] = (userControl.FindControl("TextBox7") as TextBox).Text; newValues["City"] = (userControl.FindControl("TextBox8") as TextBox).Text; newValues["Region"] = (userControl.FindControl("TextBox9") as TextBox).Text; newValues["HomePhone"] = (userControl.FindControl("HomePhoneBox") as RadMaskedTextBox).Text; newValues["BirthDate"] = (userControl.FindControl("BirthDatePicker") as RadDatePicker).SelectedDate.ToString(); newValues["TitleOfCourtesy"] = (userControl.FindControl("ddlTOC") as DropDownList).SelectedItem.Value; newValues["Notes"] = (userControl.FindControl("TextBox1") as TextBox).Text; newValues["Address"] = (userControl.FindControl("TextBox6") as TextBox).Text; newValues["FirstName"] = (userControl.FindControl("TextBox2") as TextBox).Text; newValues["LastName"] = (userControl.FindControl("TextBox3") as TextBox).Text; newValues["HireDate"] = (userControl.FindControl("HireDatePicker") as RadDatePicker).SelectedDate.ToString(); newValues["Title"] = (userControl.FindControl("TextBox4") as TextBox).Text; //make sure that unique primary key value is generated for the inserted row newValues["EmployeeID"] = (int)this.Employees.Rows[this.Employees.Rows.Count - 1]["EmployeeID"] + 1; try { foreach (DictionaryEntry entry in newValues) { newRow[(string)entry.Key] = entry.Value; } this.Employees.Rows.Add(newRow); this.Employees.AcceptChanges(); } catch (Exception ex) { Label lblError = new Label(); lblError.Text = "Unable to insert Employees. Reason: " + ex.Message; lblError.ForeColor = System.Drawing.Color.Red; RadGrid1.Controls.Add(lblError); e.Canceled = true; } } protected void RadGrid1_DeleteCommand(object source, GridCommandEventArgs e) { string iD = (e.Item as GridDataItem).OwnerTableView.DataKeyValues[e.Item.ItemIndex]["EmployeeID"].ToString(); DataTable employeeTable = this.Employees; if (employeeTable.Rows.Find(iD) != null) { employeeTable.Rows.Find(iD).Delete(); employeeTable.AcceptChanges(); } }