473,320 Members | 2,158 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Set radiobutton checked in itemdatabound creates span?

Greetings all.

I have looked far and wide but found nothing to help me with this. My datagrid has a hidden column with an id number bound to it. Then there is a column of radio buttons. (Then more columns of data.) If the value of the "priority" field in the data is 1, then that item's radio button should be selected. (Eventually, I want users to be able to select some other row to be #1, but I will deal with that later.) So I have this in a templated column in the data grid:

. . .
<itemtemplate>
<asp:radiobutton id="lead_rad" runat="server" oncheckedchanged="NewPriority"></asp:radiobutton>
</itemtemplate>
. . .

and this code in the OnItemDataBound handler:
Expand|Select|Wrap|Line Numbers
  1. RadioButton rb;
  2. Int16 p;
  3.  
  4. if (e.Item.ItemType == ListItemType.Item|e.Item.ItemType == ListItemType.AlternatingItem){
  5.    p = Convert.ToInt16(DataBinder.Eval(e.Item.DataItem, "priority"));
  6.    rb = (RadioButton)e.Item.Cells[1].FindControl("lead_rad");
  7.    if(p==1){rb.Attributes.Add("checked","true");}
  8. ...}
  9.  
What I get at runtime is this:

<span checked="true"><input id="news_dg__ctl5_lead_rad" type="radio" name="news_dg:_ctl5:news_dg:_ctl5:lead_rad" value="lead_rad" /></span>

I dunno where the span comes from, especially since I am adding a "confirm" pop-up to the delete button in the same handler and it works like a charm.

Any help welcome, abuse tolerated.
Sep 10 '07 #1
0 1248

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: rodrigo | last post by:
I have a Asp.net table control that I dynamically add rows from a SQL database. Inside the table, I add radiobuttons and they all have different ID numbers according to BindChain() Looking In...
3
by: sofie | last post by:
Hello all, I use the following javascript function in a html document to set the level of one of eight available radiobuttons. The line that's commented out works fine under IE, but I need to...
3
by: dave | last post by:
I have half a dozen web form radio buttons on a web form. Each of them is set to postback=true. However, if for instance radiobutton1 is already selected and the user selects it again, it performs...
2
by: John Holmes | last post by:
I am using radioButton controls in a data repeater and would like to incorporate the 'key' field into the 'id' attribute of the radioButton controls and name them something like: 'rad' + '<%#...
2
by: Mick | last post by:
Hi, Got a repeater which display question answers and which contains a placeholder. In the ItemDataBound Event, I insert a Radio Button for each answer and set their GroupName with the Question...
1
by: epigram | last post by:
I've got the following sytle: input.bigRadio { width: 45px; height: 45px; padding: 0px 0px 0px 0px} which I am applying to radio buttons to make them larger by applying this bigRadio class as...
4
by: Igor | last post by:
RadioButton have property Checked (true or false). If I make RadioButtons with code, without drawing by mouse than I have problems. I write like this: Dim rb(0 To 2) As RadioButton Dim n As...
1
by: Renjini Mary | last post by:
hi... i cant seem to get value of set of radio buttons thru javscripting.. i hv set values to the radiobuttons but cannot retrieve them or calculate them in JS although it looks simple. do i need to...
8
by: =?Utf-8?B?UmljaA==?= | last post by:
If you enclose a group of radiobuttons (option buttons in MS Access) in an option group control (a frame control) in Access -- the frame control will return the index of the option button that is...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.