You must Sign In to post a response.
  • Category: ASP.NET

    Regarding for database operation

    How can i view the data from database using a linkbutton in using gridview
  • #766523
    you can try this code for hyperlink and navigate another Page Details show in label Fields.

    Client Side

    <asp:GridView ID="DtgProduct" runat="server" AutoGenerateColumns="false">
    <asp:TemplateField HeaderText = "Id" ItemStyle-Width="30">
    <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%# Eval("Id", "~/ViewDetails.aspx?Id={0}") %>'
    Text='<%# Eval("Id") %>' />
    <asp:BoundField DataField="Product" HeaderText="Product" ItemStyle-Width="150" />
    <asp:BoundField DataField="Amount" HeaderText="Amount" ItemStyle-Width="150" />
    <asp:HyperLink ID="HyperLink2" runat="server" NavigateUrl='<%# string.Format("~/ViewDetails.aspx?Id={0}&Product={1}&Amount={2}",
    HttpUtility.UrlEncode(Eval("Id").ToString()), HttpUtility.UrlEncode(Eval("Product").ToString()), HttpUtility.UrlEncode(Eval("Amount").ToString())) %>'
    Text="View Details" />

    Server Side

    if (!this.IsPostBack)
    lblId.Text = HttpUtility.UrlDecode(Request.QueryString["Id"]);
    lblProductName.Text = HttpUtility.UrlDecode(Request.QueryString["Product"]);
    lblAmountText = HttpUtility.UrlDecode(Request.QueryString["Amount"]);

    Name : Dotnet Developer-2015
    Email Id

    'Not by might nor by power, but by my Spirit,' says the LORD Almighty.

  • #766537

    Kindly Go through the Below Mentioned Links regarding view the data from database while clicking the Link Button in Gridview. It may Helps you lot to do your requirement.





  • #766541

    What you have tried so far?

    Without tried out by your self simply posting for others help that won't helpful to you to learn any technology.

    As per your query when you click linkbutton inside gridview you have to perform some action over there, this task you can achieve in no of ways.

    1) Using GridView RowCommand event, pass CommandName for that linkbutton and use that linkbutton commandname you need to perform action in rowcommand event of gridview, for more details refer below link.

    2) Using Gridview HyperLinkField template you can achieve this, refer below link for more details

    and coming back to your question again, you need to fetch data from database after perform this action, so you need to get data from database and bind the same as you want.

    Give respect to your work, Instead of trying to impress your boss.

    Blog :

  • #766598
    Create page with link button, From the link button you can navigate the page. If you want you can send some input data using the query string. It is depend on your requirement. In the page load you can make the DB call and get the data from the database. Once you get the data source you can do the data binding to the GridView.
    In Aspx page create the control for Gridview. If you do not have any logic to handle in the link button just navigate the same page.

    <script language="C#" runat="server">

    void LinkButton_Click(Object sender, EventArgs e)
    MyGridView.DataSource = aDataTableL;
    < asp:LinkButton id="LinkButton1"
    Text="Click Me"

    <asp:GridView ID="MyGridView" runat="server" Width="550px"
    AutoGenerateColumns="true" ShowFooter="true">

    By Nathan
    Direction is important than speed

Sign In to post your comments