E
Emil
Can somebody tell me what would be the syntax for having an if statement and
setting the selected index of a radiobuttonlist?
This is my first project using ASP.net and I use C#.
I have a repeater with like a table layout and in the last column I want to
have three radio buttons (for each row in repeater). The value of the radio
button should be calculated from a value from the dataset.
How can I do that? When I try to use a variable inside the <asp:listitem
..... runat=server/> tag I get an error saying that I cannnot use varibles in
a server control.
Sample code (it will be inside a table which I do no show in this sample,
for clarity)
<asp:repeater id="rptEstimates" runat="server">
<HeaderTemplate>............</HeaderTemplate>
<ItemTemplate>
<%#DataBinder.Eval(Container,"DataItem.ProjectName")%>
...here I have a few more bound columns
...here I want to have an if statement to check the value from the daset
and to set the selected index value of the radiobuttonlist
<script runat=server>
string val=(string)ds.Fields.Item["BidResponse"];
if(val.Equals("Y"){rb1.SelectedIndex=0;}
</script> (this does not work)
<asp:RadioButtonList id="rb1" SelectedIndex=selIndex Runat=server>
<asp:ListItem Value=Y>Yes</asp:ListItem>
<asp:ListItem Value=N>No</asp:ListItem>
<asp:ListItem Value=NR>Nr</asp:ListItem>
</asp:RadioButtonList>
</ItemTemplate>
</asp:reapeater>
thank you.
setting the selected index of a radiobuttonlist?
This is my first project using ASP.net and I use C#.
I have a repeater with like a table layout and in the last column I want to
have three radio buttons (for each row in repeater). The value of the radio
button should be calculated from a value from the dataset.
How can I do that? When I try to use a variable inside the <asp:listitem
..... runat=server/> tag I get an error saying that I cannnot use varibles in
a server control.
Sample code (it will be inside a table which I do no show in this sample,
for clarity)
<asp:repeater id="rptEstimates" runat="server">
<HeaderTemplate>............</HeaderTemplate>
<ItemTemplate>
<%#DataBinder.Eval(Container,"DataItem.ProjectName")%>
...here I have a few more bound columns
...here I want to have an if statement to check the value from the daset
and to set the selected index value of the radiobuttonlist
<script runat=server>
string val=(string)ds.Fields.Item["BidResponse"];
if(val.Equals("Y"){rb1.SelectedIndex=0;}
</script> (this does not work)
<asp:RadioButtonList id="rb1" SelectedIndex=selIndex Runat=server>
<asp:ListItem Value=Y>Yes</asp:ListItem>
<asp:ListItem Value=N>No</asp:ListItem>
<asp:ListItem Value=NR>Nr</asp:ListItem>
</asp:RadioButtonList>
</ItemTemplate>
</asp:reapeater>
thank you.