protected void gvUser_ItemCommand(object sender, GridCommandEventArgs e){ if (e.CommandName == RadGrid.InitInsertCommandName) { e.Canceled = true;
... some code ... }}protected void gvUser_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e) { if (e.Item is GridCommandItem) { LinkButton addButton = e.Item.FindControl("InitInsertButton") as LinkButton; addButton.Attributes["onclick"] = "return ShowInsertForm();"; } }function ShowInsertForm() { window.radopen("Bearbeiten.aspx?umleitung=-1", "rwBearbeiten"); return false;}<telerik:RadWindowManager ID="rwmBearbeiten" runat="server" EnableShadow="true"> <Windows> <telerik:RadWindow ID="rwBearbeiten" runat="server" ShowContentDuringLoad="false" Width="800px" Height="650px" Title="Bearbeite Umleitungsdaten" Behaviors="Default" Modal="true" ReloadOnShow="true"> </telerik:RadWindow> </Windows></telerik:RadWindowManager>Hi Folks,
first of all, I'm new to Telerik controls. I'm using a RadGrid to display some data, which contains a DropDown column. The grid is bound to a data table on the page load event. Source of this is a SQL server. Here some Code of my binding:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load Dim table_competitor_work As DataTable = getSQLData("SELECT competitor, value, units FROM competitor_work") RadGrid1.DataSource = table_competitor_work RadGrid1.DataBind()End SubProtected Function getSQLData(ByVal query As String) As DataTable Dim connString As String = "Data Source=home-sps2010\POWERPIVOT;Initial Catalog=marketsurvey;Integrated Security=SSPI;" Dim conn As New SqlConnection(connString) Dim cmd As SqlCommand = New SqlCommand(query, conn) conn.Open() Dim dr As SqlDataReader = cmd.ExecuteReader(CommandBehavior.CloseConnection) Dim dt As New DataTable dt.Load(dr) conn.Close() Return dtEnd Function
And here is my markup code:
<telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="False" AutoGenerateDeleteColumn="True" AutoGenerateEditColumn="True" CellSpacing="0" GridLines="Horizontal" Skin="Telerik" AllowAutomaticDeletes="True" AllowAutomaticInserts="True" AllowAutomaticUpdates="True"> <MasterTableView CommandItemDisplay="Top" CommandItemSettings-AddNewRecordText="Add new customer"> <CommandItemSettings ExportToPdfText="Export to PDF" /> <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column"> <HeaderStyle Width="20px" /> </RowIndicatorColumn> <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column"> <HeaderStyle Width="20px" /> </ExpandCollapseColumn> <Columns> <telerik:GridDropDownColumn EmptyListItemText="Empty" EmptyListItemValue="Empty" FilterControlAltText="Filter Customer column" HeaderText="Competitor" UniqueName="Competitor" DataField="competitor"> </telerik:GridDropDownColumn> <telerik:GridNumericColumn DecimalDigits="2" FilterControlAltText="Filter Value column" HeaderText="Value 2010" UniqueName="Value" DataField="value"> </telerik:GridNumericColumn> <telerik:GridNumericColumn DecimalDigits="0" FilterControlAltText="Filter Units column" HeaderText="Units 2010" UniqueName="Units" DataField="units"> </telerik:GridNumericColumn> </Columns> <EditFormSettings> <EditColumn FilterControlAltText="Filter EditCommandColumn column"> </EditColumn> </EditFormSettings> </MasterTableView> <FilterMenu EnableImageSprites="False"> </FilterMenu> <HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default"> </HeaderContextMenu> </telerik:RadGrid>
The strange thing is, the binding an everything works not on the dropdown column. Nothing is displayed and I don't now why. I wanted to bind the dropdown column to a sql datasource and in the insert and edit forms I wanted to diplay other data for the dropdown list. I thought I can do it that way:
DataField="SQLserverField" (bound in code behind at runtime)
DataSourceID="SQLDataSource" (same database, but other table)
ListTextField="SQLDataSourceField"
ListValueField="SQLDataSourceField"
But that isn't working so well. Still there are no value displayed in the grid. But On insert and edit the right values are there.
Do you have an idea?
Thanks and regards,
Mark
<tr> <td><p><strong>Start Date: </strong></p></td> <td> <telerik:RadDateTimePicker runat="server" ID="rdtpStartDate" Skin="Windows7" DbSelectedDate='<%#Bind("StartDate") %>' ClientEvents-OnDateSelected="dateSelected" /> <asp:RequiredFieldValidator runat="server" Display="None" ErrorMessage="Start Date is required." EnableClientScript="true" ControlToValidate="rdtpStartDate" /> </td></tr><tr> <td><p><strong>End Date: </strong></p></td> <td> <telerik:RadDateTimePicker runat="server" ID="rdtpEndDate" Skin="Windows7" DbSelectedDate='<%#Bind("EndDate") %>' /> <asp:RequiredFieldValidator runat="server" Display="None" ErrorMessage="End Date is required." EnableClientScript="true" ControlToValidate="rdtpEndDate" /> </td></tr><script language="javascript" type="text/javascript"> function dateSelected(sender, args) { var hv = document.getElementById('<%=this.hvEndDateId.ClientID %>').value; var edp = $find(hv); var newDate = sender.get_selectedDate(); edp.set_minDate(newDate); } </script>