Hi there,
I have a problem with the Grid not returning the text I have in my RadComboBox.
I have got a grid with a GridTemplateColumn, with a RadComboBox and checkboxes like so:
And using a sql datasource and using the getuserlist stored procedure to retrieve the roles :
Roles come back as a comma separated string and the procedure that inserts them can handle it like: 'Role1, Role2' as parameter
But in edit/insert mode, I need to fill the RadComboBox and the checkboxes so I can select any of the ones I have.
So I have a oncheckboxclick that modfies the RadComboBox
So this all works until I check the roles in the command parameters:
And I can see the Roles parameter is empty. What I am doing wrong? I think I am not setting the griddataitem, so I looked into it...
And I have seen use reading the text property of the griddataitem with the following, so I tried to modify the text
But that doesn't work, because the Text property is readonly.
For updating I need to do the same thing obviously, plus then I need to set the initial state. I don't know which event I can use.
Thank you so much, been puzzling on this for a long time... :S
I have a problem with the Grid not returning the text I have in my RadComboBox.
I have got a grid with a GridTemplateColumn, with a RadComboBox and checkboxes like so:
<telerik:GridTemplateColumn HeaderText="Roles" UniqueName="Roles"> <EditItemTemplate> <telerik:RadComboBox ID="RadComboBox1" DataSourceID="SqlDataSource3" AllowCustomText="true" OnSelectedIndexChanged="OnSelectedIndexChanged" DataTextField="RoleName" DataValueField="RoleName" runat="server"> <ItemTemplate> <div class="combo-item-template"> <asp:CheckBox runat="server" ID="chk1" OnCheckedChanged="onCheckBoxClick" AutoPostBack="True" /> <asp:Label runat="server" ID="Label1" AssociatedControlID="chk1" Text='<%# Eval("RoleName")%>'> <%# Eval("RoleName")%> </asp:Label> </div> </ItemTemplate> </telerik:RadComboBox> </EditItemTemplate> <ItemTemplate> <asp:Label runat="server" ID="Label2"><%# Eval("RoleNames")%></asp:Label> </ItemTemplate> </telerik:GridTemplateColumn>
And using a sql datasource and using the getuserlist stored procedure to retrieve the roles :
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:SqlConnection %>" OnInserting="SqlDataSource_OnInserting"
SelectCommandType="StoredProcedure"
SelectCommand="GetUserList"
InsertCommandType="StoredProcedure"
InsertCommand="dbo.CreateUser"
>
<InsertParameters>
<asp:Parameter Name="UserName" Type="String" />
<asp:Parameter Name="Password" Type="String" />
<asp:Parameter Name="IsApproved" Type="Byte" />
<asp:Parameter Name="IsLockedOut" Type="Byte" />
<asp:Parameter Name="Email" Type="String" />
<asp:Parameter Name="Roles" Type="String" />
<asp:Parameter Name="UserId" DbType="Guid" Direction="Output" />
</InsertParameters>
Roles come back as a comma separated string and the procedure that inserts them can handle it like: 'Role1, Role2' as parameter
But in edit/insert mode, I need to fill the RadComboBox and the checkboxes so I can select any of the ones I have.
<asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:Sql_Azure %>" SelectCommand="SELECT RoleId, RoleName FROM Roles ORDER BY RoleName"> </asp:SqlDataSource>
So I have a oncheckboxclick that modfies the RadComboBox
protected
void
onCheckBoxClick(
object
sender, EventArgs e)
{
CheckBox chk = (CheckBox)sender;
RadComboBox combobox = (RadComboBox)chk.Parent.Parent;
string
text = BuildText(combobox);
combobox.Text = text;
}
So this all works until I check the roles in the command parameters:
protected
void
SqlDataSource_OnInserting(
object
sender, SqlDataSourceCommandEventArgs e)
{
DbParameterCollection CmdParams = e.Command.Parameters;
}
And I have seen use reading the text property of the griddataitem with the following, so I tried to modify the text
protected
void
OnSelectedIndexChanged(
object
sender, EventArgs e)
{
GridDataItem dataItem = (GridDataItem)combobox.Parent.Parent;
dataItem[
"Roles"
].Text = text;
}
For updating I need to do the same thing obviously, plus then I need to set the initial state. I don't know which event I can use.
Thank you so much, been puzzling on this for a long time... :S