5 Answers, 1 is accepted

To add a UserControl to a wep page first add a directive that registers the control.
<%@ Register src="WebUserControl.ascx" tagname="WebUserControl" tagprefix="uc1" %>
Then create a tag for your control where you want the control to appear. Here it is inside ItemTemplate of GridTemplateColumn
<
telerik:GridTemplateColumn
>
<
ItemTemplate
>
<
uc1:WebUserControl
ID
=
"WebUserControl1"
runat
=
"server"
/>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
Then in usercontrol add the TextBox where you want to dispaly the employee details like below.
User Control:
<
asp:TextBox
ID
=
"TextBox1"
runat
=
"server"
Text='<%# Eval( "EmployeeDetails" ) %>'></
asp:TextBox
>
Could you elaborate your requirement if it doesn't help?
Thanks,
Princy.

//The user control is Sample.ascx---Has one textbox
<asp:TextBox ID="rolesBox" runat="server" TextMode="MultiLine" ></asp:TextBox>
//In Sample.ascx.cs
public partial class Sample : BaseComponent
{
//EmployeeId is the parameter whose data should come from aspx page
[Browsable(false)]
public long EmployeeId { get; set; }
protected void Page_Load(object sender, EventArgs e)
{
TextBox rolesBox = new TextBox();
//Emp has different roles
//semproles—containes the roles related to the Employee with ID equal to EmployeeId
foreach (SmsEmployeeRole role in semproles)
{
rolesBox.Text += role.RolePkId.ToString() + Environment.NewLine;
}
}
}
//In Programme.aspx
<%@ Register Src="~/Components/Sample.ascx" TagName="eSample" TagPrefix="es" %>
//In the grid—Gets data from Objectdatasource. It has one column called ID
<telerik:GridTemplateColumn AutoPostBackOnFilter="true" UniqueName="RolesColumn" CurrentFilterFunction="Contains" >
<HeaderTemplate>
<asp:Label ID="Label1" runat="server" Text="Sample"></asp:Label>
</HeaderTemplate>
<ItemTemplate>
<es:eSample runat="server" ID="UserControlSample" EmployeeId= '<%# ((long)Eval("Id")) %>' ></es:eSample>
</ItemTemplate>
</telerik:GridTemplateColumn>
//Here The EmployeeId of usercontrol should be intialized to the Id value for each row of the grid and the textbox collecting all the addressdetails in the usercontrol should be place in the Itemtemplate column.
//When I debug the code, The EmployeeId parameters value in usercontrol is always ‘0’. But the (long)Eval(“Id”) is giving the correct Id values.

I tried passing parameter this way. but it didn't work.
Any help pls.
Thanks

Any help would be appreciated.
In the code snippet which you have given , I didn't find the place where you are passing the grid's row specific ID value to the user control.
Thank you

I have radgrid which populates the Id, Name and Address details.
Id and Name columns are from same table and I am able to bind them properly. The address details are in the different table in database
I have the requirement that I need to create a usercontrol with a textbox. This user control has the property and receives the EmployeeId value as input.
The method in the user control code behind is used to collect the address details and populates the textbox text with this information.
The thing which I am looking for is...
I have used Gridtemplatecolumn in the radgrid for address details as follows
<%@ Register Src="~/Sample.ascx" TagName="eSample" TagPrefix="es" %>
//In the grid—Gets data from Objectdatasource. It has one column called ID
<telerik:GridTemplateColumn AutoPostBackOnFilter="true" UniqueName="RolesColumn"CurrentFilterFunction="Contains" >
<HeaderTemplate>
<asp:Label ID="Label1" runat="server" Text="Sample"></asp:Label>
</HeaderTemplate>
<ItemTemplate>
<es:eSample runat="server" ID="UserControlSample" EmployeeId= '<%# ((long)Eval("Id")) %>' ></es:eSample>
</ItemTemplate>
</telerik:GridTemplateColumn>
// Here EmployeeId is the property present in the User control Sample.ascx and "Id" is the EmployeeId value from the ID column in the datasource binded to the radgrid.
//The user control is Sample.ascx---Has one textbox
<asp:TextBox ID="addressBox" runat="server" TextMode="MultiLine" ></asp:TextBox>
//In Sample.ascx.cs
public partial class Sample :
{
//EmployeeId is the parameter whose data should come from aspx page
[Browsable(false)]
public long EmployeeId { get; set; }
protected void Page_Load(object sender, EventArgs e)
{
TextBox addressBox= new TextBox();
//code to bind data to addressBox.Text
}
}
This is the way which I tried. I dont know whether it is correct or not.
Any help pls.
Thank you.