|
You can walk through the Repeater.Items[^] property to get reference to the radiobutton from each row with the FindControl method, then depending on the checked state of the radio you can decide to insert the row data to DB.
|
|
|
|
|
thanx ... but when i use the find control i get one row data. I want to loop through the whole repeater to get the radio buttons that are checked. How can i do that?
Best Regards
3ala2
|
|
|
|
|
The Items collection of the Repeater control contains the data RepeaterItem objects only, so if you want to get reference to a radio button or a child control in general in the header, footer, you can use the ItemCreated event of the Repeater control. In this event handler, you can try to access the child control of each item with the FindControl method.
|
|
|
|
|
Guess u didn't get me right.
Now my app is a form like the survey form
each question has five answers options (radio buttons)
i want to save all the user answers (the checked radio buttons only) when the user clicks submit... Is this possibe?
Best Regards
3ala2
|
|
|
|
|
Okay, am I correct in thinking that you have a repeater control to represent the survey questions, and each question with 5 answers are displayed in the ItemTemplate of the Repeater. You now want to get all the checked radios of the questions in the survey, and to do that you'll have to walk through the Items collection and for each RepeaterItem you get reference to 5 radios and check their checked property to see which one is selected. Another simpler option is that you can use the RadioButtonList instead of 5 seperate radiobuttons, and you can use the SelectedXXX properties of the control to access the selected answer.
|
|
|
|
|
This is exactly what i want
I guess i'll use the radio button way but how to split in 5's in the loop?
i mean can u give me a hint line of code or something to know where to start or what to look for? cause i've been trying to make that loop in more than one way and i couldn't, and the repeater item collection need an ArrayList which i don't have !
I really appreciate your quick response
Best Regards
3ala2
|
|
|
|
|
Basically, with multiple radio buttons you need to set the GroupName property of all 5 buttons to the same value so that the user is only allowed to choose a single item. The RadioButtonList control help you easily define a group of radiobuttons without setting the GroupName and the control will do that for you. For more information on how to use these controls you can see RadioButton and RadioButtonList Web Server Controls[^]
|
|
|
|
|
I know the group prperty but although thisseem silly, i'm new to this...
Now my repeater works fine in only displaying stuff, i meant how to group the 5's in the loop that checks which radiobuttons are checked and which are not.
what loop do i need to get all the controls
i tried this code
Dim rd as RadioButton = e.Item.FindControl("rd...")
this only works if i put a button next to each group (raw). And gives an exception when i tried to use it for all items :s
but if i put a button in the footer template for example it doesn't work
I donno what to do with it!
P.S. the radio button list creates an error when used because i can't give it the Name or Value by using the DataBinder.Eval(...)
-- modified at 8:33 Wednesday 11th October, 2006
Best Regards
3ala2
|
|
|
|
|
Can you post some code snippets on how to define the repeater control and how to bind data to it?
|
|
|
|
|
Yeah sure man...
<asp:repeater id="rptrPA" runat="server" EnableViewState="False">
<ItemTemplate>
<table style="FONT-WEIGHT: normal; FONT-SIZE: x-small; COLOR:003399; BORDER-TOP-STYLE: none; FONT-FAMILY: Tahoma; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BORDER-COLLAPSE: collapse; BACKGROUND-COLOR: whitesmoke; BORDER-BOTTOM-STYLE: none" width="100%" border="1">
<tr align="center">
<td width="30%" rowspan="2" valign="top">
<asp:Label ID="lblEF" Font-Name="Tahoma" Runat="server" ForeColor="003399">
<%#DataBinder.Eval(Container.DataItem,"FACTOR_DESC")%></asp:Label></td>
<td width="12%" valign="top">
<asp:radiobutton id="rdNA" runat="server" Text='<%#DataBinder.Eval(Container.DataItem,"NA")%>' GroupName="rdGroup"></asp:radiobutton></td>
<td width="12%" valign="top"><asp:radiobutton id="rdBelow" runat="server" Text='<%#DataBinder.Eval(Container.DataItem,"BELOW_AVERAGE")%>' GroupName="rdGroup"></asp:radiobutton></td>
<td width="12%" valign="top"><asp:radiobutton id="rdAverage" runat="server" Text='<%#DataBinder.Eval(Container.DataItem,"AVERAGE_PERFORMANCE")%>' GroupName="rdGroup"></asp:radiobutton></td>
<td width="12%" valign="top"><asp:radiobutton id="rdAbove" runat="server" Text='<%#DataBinder.Eval(Container.DataItem,"ABOVE_AERAGE")%>' GroupName="rdGroup"></asp:radiobutton></td>
<td width="12%" valign="top"><asp:radiobutton id="rdExceeds" runat="server" Text='<%#DataBinder.Eval(Container.DataItem,"EXCEEDS_REQUIREMENTS")%>' GroupName="rdGroup"></asp:radiobutton></td>
<tr align="center">
<td width="100%" colspan="6">
<div id="ddd">
<%#DataBinder.Eval(Container.DataItem,"GRADES_DESC")%>
</div>
</td>
tr>
</table>
</ItemTemplate>
<HeaderTemplate>
<table style="FONT-WEIGHT: bold; FONT-SIZE: x-small; COLOR: white; BORDER-TOP-STYLE: none; FONT-FAMILY: Tahoma; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BORDER-COLLAPSE: collapse; BACKGROUND-COLOR: #003399; BORDER-BOTTOM-STYLE: none" width="100%" border="1">
<tr align="center">
<td width="30%">Evaluation Factor</td>
<td width="12%">NA</td>
<td width="12%">Below Average</td>
<td width="12%">Average Performance</td>
<td width="12%">Above Average</td>
<td width="12%">Exceeds Requirements</td>
</tr>
</table>
</HeaderTemplate>
<FooterTemplate>
<table border="0" align="center" width="100%">
<tr>
<td> </td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td align="center">
<asp:Button ID="btnFill" Text="Go" Runat="server" CommandName="Go"></asp:Button></td>
</tr>
</table>
</FooterTemplate>
</asp:repeater>
And in the code behind i made a class to get the questions and options values for the radio buttons from the database.
Now what i need is the code that loops through "all" the repeater and fills anything "array" for example with the results that were made so that i can insert them in the database again. (Guess it should be put in the reapeater item command)
U seem very helpful ... I'm really thankful for u
Best Regards
3ala2
|
|
|
|
|
Because the button is placed inside the Repeater control, so you can use the ItemCommand event of the control as the Command event of the button is bubbled up to the repeater:
protected void rptrPA_ItemCommand(object source, RepeaterCommandEventArgs e)
{
if (e.CommandName == "Go")
{
foreach (RepeaterItem item in rptrPA.Items)
{
if(IsSelected(item, "rdNA"))
continue;
if (IsSelected(item, "rdBelow"))
continue;
if (IsSelected(item, "rdAverage"))
continue;
if (IsSelected(item, "rdAbove"))
continue;
if (IsSelected(item, "rdExceeds"))
continue;
}
}
}
private bool IsSelected(RepeaterItem item, string radioButtonID)
{
RadioButton radioButton = item.FindControl(radioButtonID) as RadioButton;
if (radioButton.Checked)
{
Response.Write(string.Format("Anwser for the question number {0} is {1} <br>", item.ItemIndex + 1, radioButton.Text));
}
return radioButton.Checked;
}
|
|
|
|
|
Hi man ...
I donno what to say man
I'm so happy now, i'm really thankful for u. Everything is working fine
Now i added another column to the repeater, it has a label that shows the factorID (questionID)
i can display it but i can't get it when i use the loop i can't reach it
i thought of a workaround but i don't think it's that good. i would save the checked values in the first dimension of a 2-dimensional array and get the label just in a seperate loop and add the factorID value to the second dimension
Do u think this is fine? or there is a better way?
Best Regards
3ala2
|
|
|
|
|
just3ala2 wrote: i can't get it when i use the loop i can't reach it
What do you mean by you can't get it? You cannot access the Label control or the label gives you empty. I don't think you need one loop to access the radios and another loop to access the label control which is also placed in the ItemTemplate.
|
|
|
|
|
I solved that problem
i made 2 loop but guess i'll drop one
Now the final touches ... In my database i save the score for the selected answer (the value of the answer). So how can i load the survey with the old filled data?
i made the sql statement and it works fine but i want the radio button that contains the value that i got from the db to be selected only.
//I want to mark the selcted values in the repeater radio buttons
Thank u very much
Best Regards
3ala2
|
|
|
|
|
What you need to do is to compare the radio's value with the selected answer and depending on the result you should set the Checked property of the control accrodingly. Basically, there are two options to do what you want:
+ You can use the data binding expression to set the Checked property in the web page aspx, in the expression you can use the ? : operator to compare the values. You can see more about this in MSDN.
+ You can use the ItemDataBound event of the Repeater control to do the checking and setting for the radio button of each RepeaterItem.
|
|
|
|
|
All done now
thank u so much minhpc_bk, i'm glad to have such great help
U r the best
Best Regards
3ala2
|
|
|
|
|
Hello,
I have a custom control property named "ImagePosition".
I need to have only two options available for this property: "Left" and "Top".
How can I do this?
Thanks,
Miguel
My Code:
' ImagePosition
<Bindable(True), Category("Layout"), DefaultValue(""), Localizable(True)> Property ImagePosition() As String
Get
Dim sImagePosition As String = CStr(ViewState("ImagePosition"))
If sImagePosition Is Nothing Then
Return String.Empty
Else
Return sImagePosition
End If
End Get
Set(ByVal Value As String)
ViewState("ImagePosition") = Value
End Set
End Property
|
|
|
|
|
If the property only has two values then you may consider defining an Enum with those two values and set the type of the propety with this Enum.
|
|
|
|
|
hi there,
I was looking for 3 regex expressions:
1.match any content before"<html>".
1.match any content between "<head>" and "</head>".
2.match any content inside a tag, eg: "<body onload='' bgcolor=''>" would return "onload='' bgcolor=''".
I was looking to read the result line by line: string[] tags = Regex.Split("")?
I have absolutely no experience with regular expressions.
thank you
|
|
|
|
|
Since you are new to the regular expression, you can start with downloading the Expresso[^] and the tutorial[^] posted here at CP.
|
|
|
|
|
I've been looking for a good colour selector for asp.net and while there are zillions out there, there are few good ones at all.
Many are still stuck on the old websafe colour palette which is dead as a dodo these days.
I have a theory but am not knowledgeable about Javascript / colour pallets etc to know if it's doable, but here's what I'm thinking of doing:
Create an asp.net server control for colour selection. Instead of the little box with hundreds of little boxes in it, each with it's own event and clickability etc, just one image, perhaps static or generated on the fly from some parameters that shows a sweep through all possible colours within a given range of colours and resolution.
When a user mouses over it or clicks in it, instead of having oodles of clickable elements inside it, you find the position clicked and then reverse calculate the color that would be at that position using a math routine of some kind.
This way you have a lighter footprint on the page content going to the browser, you can make more beautiful color selectors rather than the grids you currently see almost everywhere and the shackles of the websafe colour pallette are gone as well.
If it works then you extend it to support being inside a datagrid and databinding, attaching to an edit control to insert the selected value as hex etc etc. All the nifty things that aren't currently available.
Doable or is there a good reason why I don't see it done that way?
(variety in spelling of the word Colour intentional)
|
|
|
|
|
Wow - that sounds cool. It seems the only real issue would be in mapping a point back to a color in the map.
Sounds like a CP article in the making...
|
|
|
|
|
Cool, sounds like it might be doable then. Unfortunately I'm not the person capable of doing it, I would love to see such a component and so would a *lot* of people out there (judging by the threads I've come across searching for such a component).
I hope someone takes this on as an article, if not I'll revisit it in about a year when I have the time to actually learn what I need to in order to do it.
The math is what would hold me up, I was never very good at it and this probably requires something along the lines of formulas used in video games to detect where a point was clicked if it's anything other than a simple square.
Plus it would have to work in Opera, Mozilla / FF and IE as well to be of any widespread use.
|
|
|
|
|
Im looking for a query who get result in packages
let me explain
select * from users where codgroup = 1
i get all the user belongs to group 1 (100 users)
i want a query who get the rows by package (ten could be).
PD: Only sql statements, not using paging gridview property
I hope you can help me
keep Learning and you never will be out of date...
|
|
|
|
|
I'm not sure what this has to do with asp.net, perhaps try the correct forum which in this case would be the SQL one and you might have more luck. Also your question is a little unclear by what you mean by "packages".
|
|
|
|