Solved

i want to create html table using linq query that to in the .aspx page (not in aspx.cs page)

Posted on 2008-11-03
4
718 Views
Last Modified: 2013-11-11
i want to create html table dynamically using linq query but in the .aspx page (not in aspx .cs page)

something like this......
<table>
    <% var menu=from mnu in ever.L_MENU_MASTERs
        where mnu.FK_PARENT_ID == 0
        select new { mnu };
                  %>               
           <%if mnu.count>0%> 
blah blah...
create   <tr > and <td>                
                          
    </table>

Open in new window

0
Comment
Question by:sathyanreddy
  • 2
  • 2
4 Comments
 
LVL 21

Expert Comment

by:naspinski
ID: 22866659
That will be easy.

First, in grab a LinqDataSource from your toolbox, and drag it on to the page.  Configure it to pull the information you want from the database.

Then pull in a gridview and set that LinqDataSource as the DataSource.

Table made!
0
 

Author Comment

by:sathyanreddy
ID: 22873993
Hi thanks for repling but i want to show data in a html table not in Grid view.
i have already done it for ado.net now i need it for linq
Any suggestion plz......
0
 
LVL 21

Accepted Solution

by:
naspinski earned 250 total points
ID: 22874017
A gridview is a table.

But if you want to write it manually, you could use a repeater:
<table>
    <asp:Repeater ID="rpt" runat="server" 
        DataSourceID="LinqDataSource_You_Made">
        <ItemTemplate>
            <tr>
                <td><%# Eval("a_column") %></td>
                <td><%# Eval("another_one") %></td>
            </tr>
        </ItemTemplate>
    </asp:Repeater>
</table>

Open in new window

0
 

Author Comment

by:sathyanreddy
ID: 22875131
Hi thanks
It almost suits my situation but i need the grid should ot be loaded every time i.e
if (ispostback==false)
{
gridfill()
}
that i am unable to do with ur coding

as am writing urs coding in the following way

<table>
    <asp:Repeater ID="rpt" runat="server"
        DataSourceID="LinqDataSource1">
        <ItemTemplate>
       
            <tr>
                <td style="display:none;"><%# Eval("PK_ID")%></td>
                <td>
                <a href="" onclick='javascript:return redirect(<%# Eval("PK_ID")%>);return false;'><%# Eval("MENU_NAME")%></a></td>



and with java script

function redirect(id){
    alert(id);
    location.href = "Default3.aspx?pkid='" + id;
        alert(location.href);
   
}

            </tr>
        </ItemTemplate>
       
    </asp:Repeater>
   
</table>


which is not redirecting
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: block…
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now