English 中文(简体)
检索并展示从SQ库数据库到ASP的动态内容。 NET pages
原标题:Retrieving and displaying dynamic content from SQL database into ASP.NET pages
  • 时间:2012-04-17 05:45:41
  •  标签:
  • c#
  • asp.net

I am currently working on the development of news portal website in asp.net. I have created a table in sql server 2008 with parameters (NewsId, NewsTitle, NewsDetails, NewsCategory). I am now able to dynamically retrieve the NewsTitle from the database and displaying it in my aspx page. Now I want to pass the NewsId for that particular NewsTitle and then retrieve the NewsDetails in a separate aspx page. What is the best thing to do this in ASP.NET? I don t want to create new aspx pages every time a link to the NewsTitle is clicked, rather I am interested to use the same Details page and pass different ID parameters?

目 录

问题回答

我把他们放在同一个网页上,并采用像小组这样的办法,采用总细节模式来吸引人们的注意:

http://leedumond.com/blog/master-detail-editing-inserting-deleting-with-a-listview-and-detailsview/"rel=“nofollow” http://leedumond.com/blog/master-detail-editing-inserting-deleting-with-a-listview-and-details/

这将给你基本的想法;与显示这两种情况有关的样本,但正如我所说的那样,把它们引向一个纽州,然后点击。

您可以采取以下做法:

  1. • 在“Gridview”中用超链接显示“新闻”。

    <asp:GridView ID="GridView1" runat="server">
        <Columns>
            <asp:TemplateField>
                <ItemTemplate>
                     <asp:HyperLink runat="server" ID="hl" NavigateUrl= <%#"NewsDetails.aspx?Newsid="+ Eval("NewsId") %>  Text= <%# Eval("NewsTitle") %> ></asp:HyperLink>
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>
    </asp:GridView>
    

    4. 编辑《意见》中的数据来源如下:

    protected void getNewsDetails()
    {
        DataTable dtNewsDetails = new DataTable();
        //retrieve data from database into the DataTable
        GridView1.DataSource = dtNewsDetails;
        GridView1.DataBind();
    }
    
  2. 如今,GredView VirLink将浏览《新闻》。 缩略语 简言之,在《通讯》中相应地列出了细节。 页: 1

    protected void Page_Load(object sender, EventArgs e) { string Newsid = Request.QueryString["Newsid"].ToString(); //show the details from database using Newsid }

您可以添加一个文本Box,其明显属性被称作“法尔”,当你检索《新闻》时,它就将它放在文字Box上,并将其引向真实;

<asp:TextBox ID="NewsDetails" runat="server" TextMode="MultiLine" 
                        Height="30px" Width="200px" Visible="False" />

以及

void GetNewsDetails()
{
NewsDetails.Text=GetDetailsQuery;
NewsDetails.Visible=True;
}




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签