<asp:repeater id="repFareDetail" runat="server" onitemdatabound="repFareDetail_ItemDataBound" onitemcreated="repFareDetail_ItemCreated" onitemcommand="repFareDetail_ItemCommand" oninit="repFareDetail_Init"> /*This a row of repeater control*/ <ItemTemplate> <table style="width: 100%; height: 100%; font-family: 'Arial Unicode MS'; border-right-style: solid; border-top-style: solid; border-left-style: solid; border-width: thin;" bgcolor="#E6F1F7"> <tr align="center"> <td style="font-weight: bold;" class="style3"> <asp:Label ID="lblHeadFareType" runat="server" Text="Fare Type"></asp:Label> </td> <asp:gridview id="gdvDetails" runat="server" autogeneratecolumns="False" showheader="False" backcolor="#E6F1F7" style="width: 100%; height: 100%" bordercolor="#E6F1F7" visible="True" onrowcreated="gdvDetails_RowCreated"> <Columns> <asp:TemplateField> <ItemTemplate> /* This is a row of GridView control */ <td style="width: 5%;"> /*This is a Literal whcih is a place holder for code which I will be putting through by .cs file */ <asp:literal id="RadioButtonMarkup" runat="server"></asp:literal> </td> </tr> </table> </ItemTemplate> </asp:TemplateField> </Columns> </asp:gridview> </ItemTemplate> </asp:repeater>
protected void repFareDetail_ItemDataBound(object sender, RepeaterItemEventArgs e) { try { // A Class level variable which gets incremented at each loop of repeater control. i = i + 1; objServiceInteraction = clsUserInteractionFactory.GetServiceDetailResult(); strItemValue = DataBinder.Eval(e.Item.DataItem, "PUBID").ToString(); DataTable dt2 = objServiceInteraction.GetResultForDetail(strItemValue); GridView gvGridView = e.Item.FindControl("gdvDetails") as GridView; gvGridView.DataSource = dt2; gvGridView.DataBind(); } catch (Exception expSearchResult) { Server.Transfer("~/Error/Error.aspx?ErrorMessage=" + expSearchResult.Message, false); } } protected void gdvDetails_RowCreated(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { Literal output = (Literal)e.Row.FindControl("RadioButtonMarkup"); /*Using the above value of i in name field*/ output.Text = string.Format(@"<input name=""gpRadio{0}"" type=""radio"" />", i); /* You can pass a value also to this radio button which you may want to retirve after form is posted */ value='<%# Eval("CategoryID") %>' } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)