Hello,
I have an ItemTemplate in my RadListBox with a Label and an anchor tag. I am not binding the a datasource to this RadListBox, rather adding RadListBoxItem one by one. I want the Text property of RadListBoxItem to be mapped to the asp:Label in the template and when I click on the delete anchor tag, the item should be deleted. Can someone help me on this?
Thanks,
Saquib
I have an ItemTemplate in my RadListBox with a Label and an anchor tag. I am not binding the a datasource to this RadListBox, rather adding RadListBoxItem one by one. I want the Text property of RadListBoxItem to be mapped to the asp:Label in the template and when I click on the delete anchor tag, the item should be deleted. Can someone help me on this?
<
ItemTemplate
>
<
span
>
<
asp:Label
Text
=
"how to bind
" runat="server"></
asp:Label
>
</
span
>
<
span
>
<
a
href
=
"#"
onclick
=
"how to delete"
>Delete</
a
></
span
>
</
ItemTemplate
>
Thanks,
Saquib
5 Answers, 1 is accepted
0
Shinu
Top achievements
Rank 2
answered on 30 Apr 2013, 04:42 AM
Hi,
Try the following.
aspx:
Thanks,
Shinu
Try the following.
aspx:
<
asp:Label
ID
=
"Label1"
runat
=
"server"
Text='<%# Eval("ID") %>'></
asp:Label
>
Thanks,
Shinu
0
Saquib
Top achievements
Rank 1
answered on 30 Apr 2013, 11:49 AM
Shinu,
I am binding RadListBoxItems to the RadListBox, which has 'Text' and 'Value'. I don't have any field called ID that I could bind the text property of label.
I tried
I have also tried
Thanks,
Saquib.
Text='<%# Eval("ID") %>'
I am binding RadListBoxItems to the RadListBox, which has 'Text' and 'Value'. I don't have any field called ID that I could bind the text property of label.
I tried
Text='<%# Eval("Text") %>',
but it doesn't work. Can you take a look further please.I have also tried
<%# DataBinder.Eval(Container, "Text") %> and<%# DataBinder.Eval(Container, "Attributes['Text']") %>None of them works.
Thanks,
Saquib.
0
Shinu
Top achievements
Rank 2
answered on 02 May 2013, 05:04 AM
Hi,
Before the template can use the ListBox item properties to bind the elements in the template, the application needs to explicitly bind the items by calling the DataBind method of RadListBox.
c#
Thanks,
Shinu
Before the template can use the ListBox item properties to bind the elements in the template, the application needs to explicitly bind the items by calling the DataBind method of RadListBox.
c#
protected
void
Page_Load(
object
sender, EventArgs e)
{
if
(!Page.IsPostBack)
{
RadListBox1.DataBind();
}
}
Thanks,
Shinu
0
Jacek
Top achievements
Rank 1
answered on 14 May 2013, 08:54 AM
I am trying to update database from RadComboBox value in template. How to do it?
<
asp:SqlDataSource
ID
=
"SqlDataSource3"
runat
=
"server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT [ID], [Name], [Order], poziom FROM [Cities1] ORDER BY [Order]"
InsertCommand="INSERT INTO [Cities1] ([Name], [Order]) VALUES (?,?)"
DeleteCommand="DELETE FROM [Cities1] WHERE [ID] = ?"
UpdateCommand="UPDATE [Cities1] SET [Name] = ?, [Order] = ?, [poziom] = ? WHERE [ID] = ?"
ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>">
<
UpdateParameters
>
<
asp:Parameter
Name
=
"Name"
Type
=
"String"
/>
<
asp:Parameter
Name
=
"Order"
Type
=
"Int32"
/>
<
asp:Parameter
Name
=
"poziom"
Type
=
"Int32"
/>
<
asp:Parameter
Name
=
"ID"
Type
=
"Int32"
/>
</
UpdateParameters
>
<
InsertParameters
>
<
asp:Parameter
Name
=
"Name"
Type
=
"String"
/>
<
asp:Parameter
Name
=
"Order"
Type
=
"Int32"
/>
</
InsertParameters
>
<
DeleteParameters
>
<
asp:Parameter
Name
=
"ID"
Type
=
"Int32"
/>
</
DeleteParameters
>
</
asp:SqlDataSource
>
<
telerik:RadListBox
ID
=
"RadListBox2"
runat
=
"server"
AllowAutomaticUpdates
=
"True"
DataKeyField
=
"ID"
DataTextField
=
"Name"
DataValueField
=
"ID"
DataSourceID
=
"SqlDataSource3"
AllowDelete
=
"True"
AutoPostBack
=
"True"
AutoPostBackOnDelete
=
"True"
AutoPostBackOnReorder
=
"True"
AutoPostBackOnTransfer
=
"True"
TransferToID
=
"RadListBox1"
Width
=
"300px"
>
<
ButtonSettings
TransferButtons
=
"All"
position
=
"Left"
></
ButtonSettings
>
<
ItemTemplate
>
<
asp:Label
ID
=
"Label1"
runat
=
"server"
Text='<%# Eval("Name") %>'></
asp:Label
>
<
telerik:RadComboBox
ID
=
"RadComboBox1"
Runat
=
"server"
DataSourceID
=
"SqlDataSource1"
DataTextField
=
"opis"
DataValueField
=
"id"
SelectedValue='<%# Eval("poziom") %>'>
</
telerik:RadComboBox
>
</
ItemTemplate
>
</
telerik:RadListBox
>
0
Hello Jacek ,
The automatic database updates are indented to work regarding the three operations of the RadListBox : Transfer, Delete, Reorder. This is why, the functionality you attempt to achieve could not be implemented. However, I would suggest you to manually update the database at a desirable event handler of the RadComboBoxes or on a certain Button's Click event handler.
Regards,
Nencho
the Telerik team
The automatic database updates are indented to work regarding the three operations of the RadListBox : Transfer, Delete, Reorder. This is why, the functionality you attempt to achieve could not be implemented. However, I would suggest you to manually update the database at a desirable event handler of the RadComboBoxes or on a certain Button's Click event handler.
Regards,
Nencho
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.