views:

38

answers:

0

I had datalist which bind medthod which Retrieve data from data base and I had field called (Option) and other called (Value) and any Option had more values .and I could Retrieve these data well but all values under them and also options as.

Option1

Option2

Option3

 Value1
 Value2
 Value3

And the result must be

Option1

Value1

Value2

Option2

Value3

So what I can do to avoid this Repetition

<aspx>

   <tr>
                        <td valign="top">
                            <table width="902" border="0" align="center" cellpadding="0" cellspacing="0">
                                <tr>
                                    <td valign="top" class="tm8 bm8">
                                        <asp:DataList ID="DLHome" runat="server" RepeatColumns="1">
                                            <ItemTemplate>
                                                <table width="270" border="0" cellspacing="0" cellpadding="3">
                                                    <tr>
                                                        <td width="270" class="cmpr_tbl_bord_all">
                                                            <div class="cmpr_tbl_logo_a">
                                                                <asp:Image ID="IMGBrand" runat="server" ImageUrl='<%#Eval("Id","Handlers/BrandLogo.ashx?Id={0}") %>' />
                                                            </div>
                                                            <div class="cmpr_tbl_font_a cmpr_flo_r">
                                                                <asp:Label ID="LblCategory" runat="server" Text='<%# Eval("Category", "{0}") %>'></asp:Label>
                                                                <br>
                                                                <samp class="cmpr_tbl_font_b">
                                                                    <asp:Label ID="LblModel" runat="server" Text='<%# Eval("Model", "{0}") %>'></asp:Label>
                                                                </samp>
                                                            </div>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td class="cmpr_tbl_bord_all">
                                                            <table width="260" border="0" align="center" cellpadding="0" cellspacing="0">
                                                                <tr>
                                                                    <td>
                                                                        <div class="cmpr_tbl_img">
                                                                            <asp:Image ID="IMGModel" runat="server" ImageUrl='<%#Eval("Id","Handlers/Model.ashx?Id={0}") %>' />
                                                                        </div>
                                                                        <div class="cm_w cmpr_flo_r">
                                                                            <span class="cmpr_tbl_logo_b tm3">
                                                                                <asp:Image ID="ModelLogo" runat="server" ImageUrl='<%#Eval("Id","Handlers/ModelLogo.ashx?Id={0}") %>' />
                                                                            </span><span class="cmpr_tbl_but_d">
                                                                                <asp:ImageButton ID="IMGSite" ImageUrl="images/products_details.png" Width="94" Height="24"
                                                                                    border="0" runat="server" OnClick="IMGSite_Click" /></span></div>
                                                                    </td>
                                                                </tr>
                                                            </table>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td valign="top" class="cmpr_tbl_bord_all">
                                                            <asp:DataList ID="DLoption" runat="server" 
                                                                DataSource='<%# GetModelOption(Convert.ToString(Eval("Model_Id")))%>' 
                                                                RepeatLayout="Flow">
                                                                <ItemTemplate>
                                                                    <div class="cmpr_tbl_font_b_l cmpr_flo_l">
                                                                        <asp:Label ID="LblOption" runat="server" Text='<%# Eval("Option", "{0}") %>'></asp:Label>
                                                                    </div>
                                                                </ItemTemplate>
                                                            </asp:DataList>
                                                            <div class="cmpr_flo_l lm15 tm10">
                                                                <asp:DataList ID="DLValue" runat="server" 
                                                                    DataSource='<%# GetModelValue(Convert.ToString(Eval("Model_Id")))%>'>
                                                                    <ItemTemplate>
                                                                        <div class="cmpr_flo_l tm2">
                                                                            <img src="images/products3_34.png" width="9" height="10" /></div>
                                                                        <div class="cmpr_tbl_font_a_l cmpr_flo_l lm2">
                                                                            <asp:Label ID="LblValue" runat="server" Text='<%# Eval("Value", "{0}") %>'></asp:Label>
                                                                        </div>
                                                                        <br />
                                                                        </div>
                                                                    </ItemTemplate>
                                                                </asp:DataList>
                                                                </div>
                                                        </td>
                                                    </tr>
                                                </table>
                                            </ItemTemplate>
                                        </asp:DataList>
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>

<cs>
protected void Add_Click(object sender, ImageClickEventArgs e)
    {
 DataTable Dt = new DataTable();
    DataAccess Cls = new DataAccess();
        DLHome.DataSource = Cls.GetModelName(DDLModel.SelectedValue);
        DLHome.DataBind();
    }