.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month

Home >> Code Snippets >> ASP.NET Controls >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Values of Selected Row from a Gridview in TextBox

Posted By:satyapriyanayak       Posted Date: April 01, 2013    Points: 40    Category: ASP.NET Controls    URL: http://www.dotnetspark.com  

Values of Selected Row from a Gridview in TextBox

Here in this Example we will learn how to get the values of selected row from a Grid view and display the values in textboxes using C# code. We can edit, update, cancel, select, and delete data also.


Default.aspx code


<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">

    <title>Untitled Page</title>


<style type="text/css">



            width: 112%;




            width: 169px;





    <form id="form1" runat="server">

    <div style="background-color: #FF9900; width: 356px;">


        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"

            DataKeyNames="id" Height="264px" onrowediting="GridView1_RowEditing"


            onselectedindexchanged="GridView1_SelectedIndexChanged" Width="379px"

            BackColor="#66CCFF" BorderColor="#FF0066"




                <asp:BoundField DataField="id" HeaderText="Id" />

                <asp:BoundField DataField="name" HeaderText="Name" />

                <asp:BoundField DataField="address" HeaderText="Address" />

                <asp:BoundField DataField="salary" HeaderText="Salary" />

                <asp:CommandField ShowEditButton="True" />

                <asp:CommandField ShowSelectButton="True" />

                <asp:CommandField ShowDeleteButton="True" />




            <SelectedRowStyle BackColor="#FF66FF" />




        <table class="style1" style="background-color: #CCFF99; height: 268px;">


                <td class="style2">



                    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>




                <td class="style2">



                    <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend