M
Michael Bohman
Hi, i have a small problem with assigning a database value to a
RadioButtonList control. On my form i have 3 user admin=1, premium=2 and
basic=3, theese values is stored in an access database in a text string.
My problem is that when i'm loading my form, it uses a repeater control
for each user by the way, I can't find a way to assign either of these
values to the RadioButtonList Control. I can read them from the database
but i wan't the ListItem to be set checked correct for each user...here
is some code...
*.aspx form
....
<asp:RadioButtonList ID="rdbtlstLevel" RepeatDirection="Vertical"
ToolTip="Admin" runat="server">
<asp:ListItem Value=1>Admin</asp:ListItem>
<asp:ListItem Value=2>Premium</asp:ListItem>
<asp:ListItem Value=3>Basic</asp:ListItem>
</asp:RadioButtonList>
.....
*.cs form
....
this.rpUser.DataSource = objDS.Tables["tblOrganisation"].DefaultView;
switch (objDS.Tables["tblOrganisation"].Rows["Level"].ToString())
{
case "1": this.rdbtlstLevel.Items[0].Selected = true;
break;
case "2":
this.rdbtlstLevel.Items[1].Selected = true;
break;
case "3":
this.rdbtlstLevel.Items[2].Selected = true;
break;
}
this.rpUser.DataBind();
....
Hence what I wan't to do is to get the values 1,2,3 from access,
transform them to either true or false and then set The correct ListItem
to checked on the *.aspx form for each user.
Any hint from someone??
//Michael
RadioButtonList control. On my form i have 3 user admin=1, premium=2 and
basic=3, theese values is stored in an access database in a text string.
My problem is that when i'm loading my form, it uses a repeater control
for each user by the way, I can't find a way to assign either of these
values to the RadioButtonList Control. I can read them from the database
but i wan't the ListItem to be set checked correct for each user...here
is some code...
*.aspx form
....
<asp:RadioButtonList ID="rdbtlstLevel" RepeatDirection="Vertical"
ToolTip="Admin" runat="server">
<asp:ListItem Value=1>Admin</asp:ListItem>
<asp:ListItem Value=2>Premium</asp:ListItem>
<asp:ListItem Value=3>Basic</asp:ListItem>
</asp:RadioButtonList>
.....
*.cs form
....
this.rpUser.DataSource = objDS.Tables["tblOrganisation"].DefaultView;
switch (objDS.Tables["tblOrganisation"].Rows["Level"].ToString())
{
case "1": this.rdbtlstLevel.Items[0].Selected = true;
break;
case "2":
this.rdbtlstLevel.Items[1].Selected = true;
break;
case "3":
this.rdbtlstLevel.Items[2].Selected = true;
break;
}
this.rpUser.DataBind();
....
Hence what I wan't to do is to get the values 1,2,3 from access,
transform them to either true or false and then set The correct ListItem
to checked on the *.aspx form for each user.
Any hint from someone??
//Michael