This is a discussion on ASP.NET Data Controls within the ASP and ASP.NET Programming forums, part of the Web Development category; Originally Posted by Venkat hey guys, can anyone give me the soultion.... There are 10 different Categories stored in PersonalityCategory ...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
| |||
| Quote:
For the first table you can use GridView. it helps for paging and for the next table you can use Reapeaters or Datalist and to bind the last table I think RadioButtonList/CheckBoxList will be used as per your functionality Just Try it out |
| Sponsored Links |
| |||
| hey rajesh, As you said i have used GridView control which helped me to reduce the code for paging when compared to the other controls. Inside this grid view control i have implemented Repeatercontrol which is best for performance when compared to the other control.... I have bind the data's information in that Reapeater control but I want to Implement the one more repeater in this repeater control. I dont know how to do it... can you help me... Below is my sample code which i have done it. <asp:gridview id="personalityCategoryGridView" runat="server" rowstyle-width="100%" autogeneratecolumns="false" datakeynames="Id" onrowdeleting="personalityButton_Click" onrowediting="skipButton_Click" allowpaging="true" onrowdatabound= "personalityCategoryGridView_DataBound" onpageindexchanging="personalityCategoryGridView_c hange" pagersettings-mode="NextPreviousFirstLast" pagesize="1" borderwidth="0" pagersettings-position="TopAndBottom" pagersettings-nextpagetext="Next Category" pagersettings-previouspagetext="Prev Category" backcolor="#edefe9" pagerstyle-height="25px" pagerstyle-cssclass="text3" pagerstyle-forecolor="#8e9b40" width="100%" bordercolor="#edefe9"> <Columns> <asp:TemplateField> <ItemStyle VerticalAlign="Top" Width="100%" CssClass="content" HorizontalAlign="left" /> <ItemTemplate> <div class="txtheader" align="left"> <big>Personality Category - <%#DataBinder.Eval(Container.DataItem, "Name")%> <br /> <br /> </big>Questions: </div> <div> <span id="Span1" runat="server" visible="false"> <%#_incQuestion = 0 %> </span> <table> <tr> <td> <asp:Repeater ID="personalityQuestionRepeater" DataSource= '<%#getPersonalityQuestion(DataBinder.Eval(Contain er.DataItem,"Id"))%>' runat="server"> <ItemTemplate> </td> </tr> <tr> <td> <table border="0" align="left"> <tr> <td class="text2" width="20px" valign="top"> <%#_incQuestion = _incQuestion + 1%> , </td> <td class="text2"> <%#DataBinder.Eval(Container.DataItem, "Name")%> <asp:Label runat="server" ID="personalityQuestionIdLabel" Text='<%#DataBinder.Eval(Container.DataItem, "Id")%>' Visible="false"></asp:Label> </td> </tr> <tr> <td> </td> </tr> </table> </ItemTemplate> </asp:Repeater> </td> </tr> </table> </div> </ItemTemplate> </asp:TemplateField> </Columns> <Columns> <asp:TemplateField> <ItemStyle Width="50px" VerticalAlign="top" CssClass="txtbold" /> <ItemTemplate> <tr> </ItemTemplate> </asp:TemplateField> </Columns> </asp:gridview>
__________________ Venkat knowledge is Power |
| |||
| Very good contribution has been made to this thread and so ive made this thread sticky. Good Luck and continue quality content posting in this thread regularly because our goal must be to get the 1st result in search engines when searched for asp.net data controls or data controls in asp.net. Thanks
__________________ Vinoth Chandar Creator of Discussweb |
| |||
| Quote:
yes it is possible to impliment another datacontrol inside the nested data control. the thing which u have to do is. Do the same process which you have done to insert a repeater inside a grid view.. i ll explain u by slight changes within your code itself <asp:GridView ID="personalityCategoryGridView" runat="server" RowStyle-Width="100%" AutoGenerateColumns="false" DataKeyNames="Id" OnRowDeleting="personalityButton_Click" OnRowEditing="skipButton_Click" AllowPaging="true" OnRowDataBound="personalityCategoryGridView_DataBo und" OnPageIndexChanging="personalityCategoryGridView_c hange" PagerSettings-Mode="NextPreviousFirstLast" PageSize="1" BorderWidth="0" PagerSettings-Position="TopAndBottom" PagerSettings-NextPageText="Next Category" PagerSettings-PreviousPageText="Prev Category" BackColor="#edefe9" PagerStyle-Height="25px" PagerStyle-CssClass="text3" PagerStyle-ForeColor="#8e9b40" Width="100%" BorderColor="#edefe9"> <Columns> <asp:TemplateField> <ItemStyle VerticalAlign="Top" Width="100%" CssClass="content" HorizontalAlign="left" /> <ItemTemplate> <div class="txtheader" align="left"> <big>Personality Category - <%#DataBinder.Eval(Container.DataItem, "Name")%> <br /> <br /> </big>Questions: </div> <div> <span id="Span1" runat="server" visible="false"> <%#_incQuestion = 0 %> </span> <table> <tr> <td><!-- the first repeater which gets the dataSource from the primary key of the grid--> <asp:Repeater ID="personalityQuestionRepeater" DataSource='<%#getPersonalityQuestion(DataBinder.E val(Container.DataItem,"Id"))%>' runat="server"> <ItemTemplate> </td> </tr> <tr> <td> <table border="0" align="left"> <tr> <td class="text2" width="20px" valign="top"> <%#_incQuestion = _incQuestion + 1%> , </td> <td class="text2"> <%#DataBinder.Eval(Container.DataItem, "Name")%> <asp:Label runat="server" ID="personalityQuestionIdLabel" Text='<%#DataBinder.Eval(Container.DataItem, "Id")%>' Visible="false"></asp:Label> </td> </tr> <tr> <td> </td> </tr> </table> <table> <tr> <td><!-- the second repeater which gets the dataSource from the primary key of the first repeater--> <asp:Repeater ID="personalityOptionsRepeater" DataSource='<%#getPersonalityOption(DataBinder.Eva l(Container.DataItem,"Id"))%>' runat="server"> <ItemTemplate> </td> </tr> <tr> <td> <table border="0" align="left"> <tr> <td class="text2" width="20px" valign="top"> <%#_incOption = _incOption + 1%> , </td> <td class="text2"> <%#DataBinder.Eval(Container.DataItem, "Name")%> <asp:Label runat="server" ID="personalityOptionIdLabel" Text='<%#DataBinder.Eval(Container.DataItem, "Id")%>' Visible="false"></asp:Label> </td> </tr> <tr> <td> </td> </tr> </table> </ItemTemplate> </asp:Repeater> </td> </tr> </table> </ItemTemplate> </asp:Repeater> </td> </tr> </table> </div> </ItemTemplate> </asp:TemplateField> </Columns> <Columns> <asp:TemplateField> <ItemStyle Width="50px" VerticalAlign="top" CssClass="txtbold" /> <ItemTemplate> <tr> </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView> In this sample i have inserted the repeater inside the repeater which was inside the grid. To make u clear i have commented* inside the sample just take a note of it Note:- *comments will be in red color Last edited by rrrajesh84in : 08-23-2007 at 12:40 AM. |
| |||
| hey rajesh, I have implemented nested repeater, from the above parent repeater i want to get the primary key which should be the referer as foreign key in nested repeater, So I have implemented the Hidden server control... <asp:HiddenField ID="HiddenField1" runat="server" /> but i am not getting the Hiddenfield value in code behind. Here is my code.... protected void personalityCategoryGridView_DataBound(object sender, GridViewRowEventArgs e) { short questionId; short optionId; foreach (GridViewRow i in personalityCategoryGridView.Rows) { Repeater personalityQuestionRepeater = (Repeater)i.FindControl("personalityQuestionRepeat er"); if (personalityQuestionRepeater != null) { if (personalityQuestionRepeater.Items.Count > 0) { foreach (RepeaterItem j in personalityQuestionRepeater.Items) { questionId = short.Parse(((System.Web.UI.WebControls.Label)j.Fi ndControl("personalityQuestionIdLabel")).Text); if (personalityOptionRadioButtonList != null) { if (personalityOptionRadioButtonList.Items.Count > 0) { for (int k = 0; k < personalityOptionRadioButtonList.Items.Count; k++) { optionId = short.Parse(personalityOptionRadioButtonList.Items[k].Value.ToString()); PersonalityDetail personalityDetail = new PersonalityDetail(); personalityDetail = personalityDetailManager.GetPersonalityDetailByUse rIdAndPersonalityQuestionId(_userSessionId, questionId); if (personalityDetail.PersonalityQuestionId == questionId) { if (personalityDetail.PersonalityOptionId == optionId) { ListItem personalityOptionRadioButton = personalityOptionRadioButtonList.Items[k]; if (personalityOptionRadioButton != null) { personalityOptionRadioButton.Selected = true; } } } } } else { personalityOptionRadioButtonList.Visible = false; emptyOptionsLabel.Visible = true; } } } } else { personalityQuestionRepeater.Visible = false; personalityButton.Visible = false; emptyQuestionLabel.Visible = true; } } } how to get the primary key value from the Parent Repeater.....
__________________ Venkat knowledge is Power |
| |||
| Quote:
The primary key of the repeater ll be in the dataBinder so at the Databound event of the particular control. u can get the id and store it in a variable and use it, for eg:- Guid questionId = new Guid(DataBinder.Eval(e.Item.DataItem, "Id").ToString()); the above code should be placed inside the DataBound event of the control Last edited by rrrajesh84in : 08-23-2007 at 09:55 AM. |
| |||
| hi the primary key can allso get thru another way by assigning the content inside the datable and access the datable content through the system. the dataTable sample is shown bellow u can try through this way also DataTable membersDataTable = new DataTable(); DataRow membersDataRow; DataView membersDataView = new DataView(); membersDataTable.Columns.Add(new DataColumn("Name")); membersDataTable.Columns.Add(new DataColumn("Description")); userGroup = userGroupManager.GetUserGroupByGroupCategoryId(gro upCategoryId); if (userGroup.Length > 0) { for (int i = 0; i < userGroup.Length; i++) { membersDataRow = membersDataTable.NewRow(); userGroupId = userGroup[i].ID; if (userGroup[i].PrivacyTypeId == 1) { membersDataRow[0] = "Public Group"; } else { membersDataRow[0] = "Private Group"; } userGroupMemberCount = userGroupMemberManager.GetUserGroupMemberCount(use rGroupId); membersDataRow[2] = userGroup[i].Name; membersDataRow[3] = userGroup[i].Description; membersDataTable.Rows.Add(membersDataRow); } membersDataView = membersDataTable.DefaultView; |
| |||
| hi rajesh, Quote:
<table> <tr> <td> </td> <td> <asp:RadioButtonList ID="personalityOptionRadioButtonList" runat="server" Width="100%" BorderWidth="0px" RepeatColumns="1" CssClass="text3" DataSource='<%#getPersonalityOption(DataBinder.Eva l(Container.DataItem,"Id"))%>' DataValueField="Id" DataTextField="Name"> </asp:RadioButtonList> <asp:Label runat="server" ID="emptyOptionsLabel" Visible="false" CssClass="text3" Text="No options move to next question."></asp:Label> </td> </tr> </table>
__________________ Venkat knowledge is Power Last edited by Venkat : 08-23-2007 at 10:43 PM. |
| |||
| Quote:
To get the Id of RadioButoon. In side the Databound event of gridview find the Repeater first then do the bellow coding. (just check out the comments which have been marked in red) foreach (RepeaterItem j in personalityQuestionRepeater.Items) { questionId = short.Parse(((System.Web.UI.WebControls.Label)j.Fi ndControl("personalityQuestionIdLabel")).Text); if (personalityOptionRadioButtonList != null) { if (personalityOptionRadioButtonList.Items.Count > 0) { for (int k = 0; k < personalityOptionRadioButtonList.Items.Count; k++) { //optionId will get the radioButton id For each cycle in // personalityOptionRadioButtonList.Items.Count optionId = short.Parse(personalityOptionRadioButtonList.Items[k].Value.ToString()); |
| |||
| hey rajesh, Its working fine i can reterive all the data through the nested repeater and radioButton is also working. Thanks for you help.... What’s the major difference between Datagrid control, Datalist control and repeater control?
__________________ Venkat knowledge is Power |
| |||
| Quote:
A Datagrid, Datalist and Repeater are all ASP.NET data Web controls.They have many things in common like DataSource Property, DataBind MethodItemDataBound and ItemCreated.When you assign the DataSource Property of a Datagrid to a DataSet then each DataRowpresent in the DataRow Collection of DataTable is assigned to a correspondingDataGridItem and this is same for the rest of the two controls also. But The HTML codegenerated for a Datagrid has an HTML TABLE <ROW> element created for the particularDataRow and its a Table form representation with Columns and Rows.For a Datalist its an Array of Rows and based on the Template Selected and theRepeatColumn Property value We can specify how many DataSource records shouldappear per HTML <table> row. In short in datagrid we have one record per row, but indatalist we can have five or six rows per row. For a Repeater Control, the Datarecords to be displayed depends upon the Templatesspecified and the only HTML generated is the due to the Templates.In addition to these, Datagrid has a in-built support for Sort, Filter and paging the Data,which is not possible when using a DataList and for a Repeater Control we would requireto write an explicit code to do paging. |