<telerik:GridEditCommandColumn UniqueName="EditCommandColumn" HeaderStyle-Width="50" EditImageUrl="~/images/edit.gif" /> |
more....grid.......code |
<EditFormSettings UserControlName="~/controls/Edit.ascx" EditFormType="WebUserControl"> |
<EditColumn UniqueName="EditCommandColumn1"> |
</EditColumn> |
</EditFormSettings> |
How do I pass the parameters in the grid like the column name, id, and date to the ascx page?
Thanks!
6 Answers, 1 is accepted

Go through the following online demo discussing about the UserControl edit form and see whether it helps.
User control edit form
Shinu.
If you have this in your UserControl:
private object _dataItem = null;
public object DataItem
{
get
{
return this._dataItem;
}
set
{
this._dataItem = value;
}
}
the grid populate automatically DataItem property on edit.
Kind regards,
Vlad
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center

That is the example I am using as a refernce, thank you for responding. But it does not show me how the dropdownlist in the user control passes the variable from the grid to the user control dropdownlist and selects the courtesy i.e. "Dr.", "Mrs.", etc.
Even with the Example below it does not show a REAL world way of binding the form data from codebehind with DataTables. I do not use magic code from drop and drag tools.
Example
I really need your assistance on this please show me what event is fired when clicking on the "Edit" link and once it's clicked how does it query the data to fill in the from!
Vlad,
Do I put this in the code behind of the user control "ascx.cs"? If so how do I access them if I want username, state, and last name from the grid?

<
asp:Label ID="MyID" Text='<%# Eval("myID")%>' runat="server" Visible="false"></asp:Label>
Now, I don't use "Page_Load" because that value won't be populated at that time. Instead, I use OnPreRender() and call a method called LoadPage() which then populates the page's data etc.. Something like this (please note that I'm using custom entities - this is only to give you an idea):
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Web.UI;
public partial class MyFormControl : ControlBase
{
#region Members
private bool _isLoaded = false;
#endregion
#region Properties
/// <summary>
/// Use MyID for primary key
/// </summary>
public string UniqueKey
{
get
{
return MyID.Text;
}
set
{
MyID.Text = value;
}
}
/// <summary>
/// Set when control is loaded
/// </summary>
private bool IsLoaded
{
get
{
return _isLoaded;
}
set
{
_isLoaded = value;
}
}
#endregion
#region Methods
/// <summary>
/// Method used to load page data.
/// </summary>
private void LoadPage()
{
PopulateDropdownList();
Populate();
}
/// <summary>
/// Populates List data
/// </summary>
private void PopulateDropdownList()
{
if (MyDropdownList.Items.Count < 1)
{
MyDropdownList.DataTextField = MyEntity.DBFieldName.Description.ToString();
MyDropdownList.DataValueField = MyEntity.DBFieldName.IDValue.ToString();
MyDropdownList.DataSource = MyEntity.GetList();
MyDropdownList.DataBind();
MyDropdownList.Items.Insert(0, new RadComboBoxItem("Select One...", String.Empty));
}
}
/// <summary>
/// Populates page data
/// </summary>
private void Populate()
{
Populate(this.UniqueKey);
}
private void Populate(string myID)
{
//get saved data
MyEntity entity = new MyEntity();
if (!String.IsNullOrEmpty(myID))
{
entity = MyEntity.GetByID(myID);
}
PopulateUIFromEntity(entity, this);
}
/// <summary>
/// Saves page data
/// </summary>
/// <returns>True if successful</returns>
public bool Save()
{
IsLoaded = true;
bool success = false;
MyEntity entity = new MyEntity();
if (!String.IsNullOrEmpty(this.UniqueKey))
{
entity = MyEntity.GetByID(this.UniqueKey);
}
//update with form data
entity = (MyEntity)PopulateEntityFromUI(entity, this);
success = entity.SaveData();
if (success)
{
//update the unique key field
this.UniqueKey = entity.MyID;
}
return success;
}
/// <summary>
/// Deletes current page data
/// </summary>
/// <returns>True if successful</returns>
public bool Delete()
{
IsLoaded = true;
bool success = false;
//TODO: Add code here
return success;
}
#endregion
#region AJAX Events
#endregion
#region Form Events
protected void Page_Load(object sender, EventArgs e)
{
}
protected void SaveButton_Click(object sender, EventArgs e)
{
this.Save();
}
protected override void OnPreRender(EventArgs e)
{
if (!IsLoaded)
{
//load page data
LoadPage();
}
base.OnPreRender(e);
}
#endregion
}

Hey Mike,
Sorry I am very late to the party but I was wondering if you ever got an answer to this question. I am having the same problem passing a parameter to the control page
Thank
Perry
I've already replied to your query in the following post. I suggest that we continue our conversation in the mentioned thread:
http://www.telerik.com/forums/need-help-with-radgrid-edititemtemplate
Regards,
Eyup
Telerik