Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > RadioButtonList in DataList EditItemTemplate

Reply
Thread Tools

RadioButtonList in DataList EditItemTemplate

 
 
Sudheer Aalla
Guest
Posts: n/a
 
      09-20-2006
Hi,

When I try to reference the radiobuttonlist control in edititemtemplate in
ItemDataBound event of datalist control I am getting NULL reference. I am
trying to pre select the yes/no button depending on the label text in item
template. But I am able to get the value of lable control which is in
itemtemplate. Is there anything else I am missing here???

public void DataListItems_ItemDataBound(object sender, DataListItemEventArgs
e)

{

if (DataListItems.EditItemIndex != -1 && e.Item.ItemIndex != -1 &&
e.Item.HasControls())

{

Label rbllblIsAdded = (Label)e.Item.FindControl("lblIsAdded");

RadioButtonList rbl =
(RadioButtonList)e.Item.FindControl("edtrblIsAdded ");

if (rbllblIsAdded.Text == "Added")

{

rbl.SelectedValue = "Yes";

}

else

{

rbl.SelectedValue = "No";

}

}

}



<EditItemTemplate>

<table width="100%" cellspacing="0" cellpadding="0" style="height:100%;">

<tr>

<td width="10%">

<asp:RadioButtonList ID="edtrblIsAdded" RepeatDirection="Horizontal"
runat="server">

<asp:ListItem Value="Yes">A</asp:ListItem>

<asp:ListItem Value="No">R</asp:ListItem>

</asp:RadioButtonList>

<asp:RequiredFieldValidator ID="RFVedtrblIsAdded" runat="server"
ErrorMessage="Please select added/removed"

ControlToValidate="edtrblIsAdded" ValidationGroup="UpdateValidationControls"
ToolTip="Please select added/removed">*</asp:RequiredFieldValidator>


</td>

........



Thanks,

Sudheer.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Entering DataList EditItemTemplate from Outside of the DataList Luis Esteban Valencia ASP .Net 1 01-06-2005 07:32 PM
Setting DataList EditItemTemplate Properties Stuart Shay ASP .Net 0 12-26-2004 05:44 AM
how do i access a dropdownlists selected value in a datagrid edititemtemplate column from the selectedindexchanged event of another dropdownlist in a datagrid edititemtemplate column Dave M ASP .Net Datagrid Control 0 12-14-2004 11:53 AM
Setting up a datalist control - Item_DataBound for a datalist in a datalist Nevyn Twyll ASP .Net 8 09-09-2004 10:13 PM
Datalist EditItemTemplate SStory ASP .Net 0 08-18-2003 11:01 PM



Advertisments