Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net (http://www.velocityreviews.com/forums/f29-asp-net.html)
-   -   RadioButtonList in DataList EditItemTemplate (http://www.velocityreviews.com/forums/t372262-radiobuttonlist-in-datalist-edititemtemplate.html)

Sudheer Aalla 09-20-2006 05:13 PM

RadioButtonList in DataList EditItemTemplate
 
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.




All times are GMT. The time now is 01:57 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.