3 Answers, 1 is accepted
0
Shinu
Top achievements
Rank 2
answered on 15 Dec 2009, 06:53 AM
Hello,
Checkout the following help documentation on customizing/configuring GridDropDownColumn.
Customize/Configure GridDropDownColumn
-Shinu.
Checkout the following help documentation on customizing/configuring GridDropDownColumn.
Customize/Configure GridDropDownColumn
-Shinu.
0
dingen
Top achievements
Rank 1
answered on 15 Dec 2009, 12:41 PM
Hi
Next question is: how can i update courtesy value in the row after editing and selecting a new value for Title of courtesy in the editmode? Code + aspx page attached:
regards
D
Next question is: how can i update courtesy value in the row after editing and selecting a new value for Title of courtesy in the editmode? Code + aspx page attached:
regards
D
| Imports System |
| Imports System.Configuration |
| Imports System.Data |
| Imports System.Data.Common |
| Imports System.Data.SqlClient |
| Imports System.Globalization |
| Imports System.Web.SessionState |
| Imports System.Web.UI |
| Imports System.Web.UI.WebControls |
| Imports Telerik.Web.UI |
| Partial Public Class Dropdown |
| Inherits System.Web.UI.Page |
| Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load |
| RadGrid1.DataSource = EmployeesData |
| End Sub |
| Private Sub Page_PreRender(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.PreRender |
| If Not MyBase.IsPostBack Then |
| Me.RadGrid1.MasterTableView.Items(0).Edit = True |
| Me.RadGrid1.MasterTableView.Rebind() |
| End If |
| End Sub |
| Private Sub RadGrid1_NeedDataSource(ByVal source As Object, ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles RadGrid1.NeedDataSource |
| RadGrid1.DataSource = EmployeesData() |
| Me.EmployeesData.Tables("Employees").PrimaryKey = New DataColumn() {Me.EmployeesData.Tables("Employees").Columns("EmployeeID")} |
| End Sub |
| Protected Sub RadGrid1_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles RadGrid1.ItemDataBound |
| If (TypeOf e.Item Is GridEditableItem AndAlso CType(e.Item, GridEditableItem).IsInEditMode) Then |
| Dim editeditem As GridEditableItem = CType(e.Item, GridEditableItem) |
| Dim editman As GridEditManager = editeditem.EditManager |
| Dim editor As GridDropDownColumnEditor = CType(editman.GetColumnEditor("CourtesyCombo"), GridDropDownColumnEditor) |
| Dim alCourtesy = New ArrayList() |
| Dim mr As New courtesy() |
| mr.TitleOfCourtesy = "mister" |
| Dim mrs As New courtesy() |
| mrs.TitleOfCourtesy = "missus" |
| alCourtesy.Add(mr) |
| alCourtesy.Add(mrs) |
| editor.DataSource = alCourtesy |
| editor.DataBind() |
| End If |
| End Sub |
| Public Shared Property EmployeesData() As DataSet |
| Get |
| Dim MyEmployeesData As DataSet = New DataSet |
| Dim ConnString As String = ConfigurationManager.ConnectionStrings("NorthwindConnectionString").ConnectionString |
| Dim conn As SqlConnection = New SqlConnection(ConnString) |
| Dim adapter As SqlDataAdapter = New SqlDataAdapter |
| adapter.SelectCommand = New SqlCommand("SELECT EmployeeID, FirstName, LastName, TitleOfCourtesy, HireDate FROM Employees", conn) |
| adapter.Fill(MyEmployeesData, "Employees") |
| Return MyEmployeesData |
| End Get |
| Set(ByVal value As DataSet) |
| End Set |
| End Property |
| End Class |
| Public Class courtesy |
| Dim _TitleOfCourtesy As String |
| Property TitleOfCourtesy() As String |
| Get |
| Return _TitleOfCourtesy |
| End Get |
| Set(ByVal value As String) |
| _TitleOfCourtesy = value |
| End Set |
| End Property |
| End Class |
| <%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Dropdown.aspx.vb" Inherits="TelerikProbeer.Dropdown" %> |
| <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> |
| <!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 runat="server"> |
| <title></title> |
| </head> |
| <body> |
| <form id="form1" runat="server"> |
| <div> |
| <telerik:RadScriptManager ID="RadScriptManager1" runat="server"> |
| </telerik:RadScriptManager> |
| <telerik:RadGrid ID="RadGrid1" runat="server" Width="96%" GridLines="None" AutoGenerateColumns="False" |
| PageSize="13" AllowSorting="True" AllowPaging="True" ShowStatusBar="true"> |
| <MasterTableView DataKeyNames="EmployeeID" AllowMultiColumnSorting="True" Width="100%" |
| CommandItemDisplay="Top"> |
| <Columns> |
| <telerik:GridButtonColumn UniqueName="DeleteColumn" Text="Delete" CommandName="Delete" /> |
| <telerik:GridBoundColumn UniqueName="FirstName" SortExpression="FirstName" HeaderText="First name" |
| DataField="FirstName" /> |
| <telerik:GridBoundColumn UniqueName="LastName" SortExpression="LastName" HeaderText="Last name" |
| DataField="LastName" /> |
| <telerik:GridDropDownColumn UniqueName="CourtesyCombo" ListDataMember="Employees" |
| SortExpression="TitleOfCourtesy" ListTextField="TitleOfCourtesy" ListValueField="TitleOfCourtesy" |
| DataField="TitleOfCourtesy" HeaderText="Title of courtesy"> |
| </telerik:GridDropDownColumn> |
| <telerik:GridBoundColumn UniqueName="HireDate" SortExpression="HireDate" HeaderText="Hire date" |
| DataField="HireDate" DataFormatString="{0:d}" /> |
| <telerik:GridEditCommandColumn UpdateText="Update" UniqueName="EditCommandColumn" |
| CancelText="Cancel" EditText="Edit"> |
| <HeaderStyle Width="85px"></HeaderStyle> |
| </telerik:GridEditCommandColumn> |
| </Columns> |
| <EditFormSettings CaptionFormatString="Edit details for employee with ID {0}" CaptionDataField="EmployeeID"> |
| <FormTableItemStyle Width="100%" Height="29px"></FormTableItemStyle> |
| <FormTableStyle GridLines="None" CellSpacing="0" CellPadding="2"></FormTableStyle> |
| <FormStyle Width="100%" BackColor="#eef2ea"></FormStyle> |
| <EditColumn ButtonType="ImageButton" /> |
| </EditFormSettings> |
| </MasterTableView> |
| </telerik:RadGrid> |
| </div> |
| </form> |
| </body> |
| </html> |
0
Princy
Top achievements
Rank 2
answered on 15 Dec 2009, 01:50 PM
Hello,
You can access the RadComboBox in the UpdateCommand, retrieve the combobox selected text and reflect changes in the database. Here's an example:
c#:
Thanks
Princy.
You can access the RadComboBox in the UpdateCommand, retrieve the combobox selected text and reflect changes in the database. Here's an example:
c#:
| protected void RadGrid1_UpdateCommand(object source, GridCommandEventArgs e) |
| { |
| GridEditableItem editItem = (GridEditableItem)e.Item; |
| RadComboBox combo = (RadComboBox)editItem["CourtestCombo"].Controls[0]; |
| string strtxt = combo.Text; |
| //pass the combo value to the update query. |
| } |
Thanks
Princy.