Accessing GridView Data Row By Row

guys i have just started with
i have a basic doubt, i have created a SQL datasource and a gridview associated with it now what i need to do is get all the data from my database n modify it further, for this i need to access each row of the gridview any ideas on how to do so?
1/18/2009 2:27:52 PM 91979 articles. 4 followers. Follow

2 Replies

Similar Articles

[PageSpeed] 29

foreach(GridViewRow row in GridViewName.Rows)


you can interate like this.. 


Better Post your code before asking some thing, some one. So that person helping u will understand u r problem Clearly

Yahoo IM : dotnetruler

I am trying to keep Frequently Asked Questions in my blog
1/18/2009 2:33:04 PM

 When u enable showeditbutton = truein gridview

you  can access and edit any row displayed in gridview , what else u need

<form id="form1" runat="server">
           <asp:DetailsView ID="DetailsView1" runat="server" DataKeyNames="ID" AutoGenerateRows="False" DataSourceID="SqlDataSource1"
            Height="50px" Width="125px">
            <asp:TemplateField HeaderText="ID" SortExpression="ID">
            <asp:Label ID="lblID" runat="server" Text='<%#Eval("ID") %>'></asp:Label>
            <asp:Label ID="lblID" runat="server" Text='<%#Eval("ID") %>'></asp:Label>
            <asp:TemplateField HeaderText="Category" SortExpression="Category">
            <asp:Label ID="lblCategory" runat="server" Text='<%#Eval("Category") %>'></asp:Label>
            <asp:TextBox ID="txtCategory" runat="server" Text='<%#Bind("Category") %>'></asp:TextBox>
             <asp:TemplateField HeaderText="Product" SortExpression="Product">
              <asp:Label ID="lblProduct" runat="server" Text='<%#Eval("Product") %>'></asp:Label>
             <asp:TextBox ID="txtProduct" runat="server" Text='<%#Bind("Product") %>'></asp:TextBox>
             <asp:CommandField ShowEditButton="True" />
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:dvConnectionString %>"
            SelectCommand="SELECT ID, Category, Product FROM Products" UpdateCommand="UPDATE Products SET Category = @Category, Product = @Product WHERE (ID = @ID)">
                <asp:Parameter Name="Category" />
                <asp:Parameter Name="Product" />
                <asp:Parameter Name="ID" />


Check the sample code attached


Don't say thanks rather mark my reply as "Answer" if it helps you ,Doing so u'll get points too
amiT jaiN

C#.NET Articles
1/18/2009 2:34:58 PM

Similar Artilces:

How to get the data of a particular row in gridview without editing that row.
I have a gridview in a page in that ihave hyperlink as one column on click of that i want to go next page with the data present in that corresponding row. How shell i read the data from grid view for that pirticular row.On which event i can get the data. HI, the row that is selected should be passed into a string or an array or in sessionsthis can be done through this code  protected void GridView1_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)    {        Label _lbl = new Label();      &...

How to get data from database row by row
I try to get data from a database row by row, I am using DataReader, the return result is not I expected, don't know how to solve it. Here is my sample code: --------------------------------------------Dim commandText As String = "select * from customer "Dim con As New OleDbConnection("Data Source=c:\company.mdb;Persist Security Info=False; Provider=Microsoft.Jet.OLEDB.4.0;")Dim Cmd As New OleDbCommand(commandText, con)Dim reader As OleDbDataReader = Cmd.ExecuteReader()             Using con       &nbs...

Populate row by row data in gridview
Hi , How to populate the data row by row in grid view. For example: I wirte this code in .aspx page <asp:TemplateField HeaderText="COC Date of Calibration">                <EditItemTemplate>                    <asp:TextBox ID="TextBox2" runat="server" Text='<%# COC_Date("strDate") %>'></asp:TextBox>       &nbs...

Data Controls insert rows into gridview then insert rows from gridview into SQL Table
Hello there, I'm still new at performing miracles with code . Currently I am having trouble with my latest coding adventure I have a web application which records jobs and labour assigned to jobs. The issue in particular I'm having is the way in which labour is to be assigned. I want to use standard controls (Textbox, Dropdownlist) to record the values into a gridview (ie,put multiple rows into the gridview using the controls). Then, when all the inserting is complete, the user clicks a submit button to insert all the rows from the gridview into a database table. The reason for...

Access GridView Row Data without cell access
Hello,I have a gridview that I modify before rendering to add custom separators between different entities. I compare the value in a particular cell with the previous value, and take action accordingly. Everything works great. However, I no longer want to display the 'entity' column in the actual gridview rows - only as a separator. So, if I remove the column from the gridview, how can I access a particular value on each row without calling a cell? Keep in mind, this takes place during the render stage and not gridRowBound. My render code is as follows: 1 Protected Overri...

How to get row selected in Gridview and then to get the data from the cells in that Grid?
I have a gridview with about 30 rows of data. If someone selects a row in the grid(Clicking or double clicking) then I want to get the values in each column/cell in that row. Once I get those values, I want to populate other edit controls on my web form with the values selected from the row. So the big question here, is how to capture the row selected from clicking or double clicking. Then how to get the column cell items?   Clickable GridView Row

copy data from excel row to gridview row
Hi All, I need to copy data from excel to gridview. I have to select a row and press Ctrl+C to copy from excel, then I have to paste it in Gridview. Thanks in advance. I dont think you can Copy and Paste data from Excel to Gridview.But you can export data from Excel to GridView control, please check the below articles. a Reply as 'Answered', not only GAIN us some POINTS, but it also HELP others to find RIGHT solution....

accessing row by row
first of all sorry if i posted this in a wrong place but i'm new to powerbuilder and i have to develop a program quite quickly ( i only worked with acces until now) i have been provided a excel spreadsheet that contains all coloms and rows from all tables wich i have to insert in a database. The difficulty is that i can't use a datapipeline because i need to use a string function to check in wich table i have to put it: TABLENAME_COLUMNNAME -> i thought about using the string function to find out the right column in the right database. however i don't know how you ...

Get row data of a GridView
Hi... I have a GridView. It contains a button as a button column. My requirement is when I select any button in a particular row the data in that particular row should be retrieved and should be added to another gridview. How can I achieve it.Any body Help me out..... Thanks in advance    HiPlease go through this below link This also talks same Thanks~Avinash desai~Software DeveloperBangalorePlease remember to click "Mark as Answer" on this post if it helped you. mrkk:Hi... I have a GridView. It contains a button as a b...

Accessing data row from Gridview
I am using Visual Web Developer 2005 and I have a Gridview displaying data that is being filtered by a dropdownlist. I.e. the dropdownlist has last names and the gridview displays only the rows with that last name. I have also enabled selection in the gridview.What I want to do is grab the email address that the user selected to send an email. I just don't know how to get the email address. I can see the email in the gridview but can't assign it to a variable. How do I do that?So the basic question is: How do you assign a field within a row that a user has selected in a gridview control to a...

Gridview Rows Backcolor getting reset when selecting a row
I have a list of rows in my gridview that list one or more entries per date.  I have coded the RowDataBound event so that all of the rows for a given date have the same backcolor.  Day 1 is white, Day 2 is yellow, Day 3 is white, day 4 is yellow - where each day could have multiple rows.  On each row, I also have an Edit imagebutton that allows each row to be edited via a separate panel and not in-line grid editing.  When I click on the Edit imagebutton, I set the gridviews selectedindex to that row and then using the skin for the grid, the selected row backco...

Gridview row editing fields based on row data
Is there a way to change row editable fields in a databound gridview based on the rows data. For example letting a user edit all his and his fellows fields but preventing him from changing specific fields in his boss data on the same gridview? Help will be great fully appreciated. Thanks If I understand what you are saying is that you want to only allow a user to Edit certain rows within the GridView. If so, yes, you certainly can do this. What I would do is hide/display the Edit Button for a row based on the user's role or permissions. This can easily be done via the RowDataBound e...

how to get id of row from check box in gridview row
this is my gridview code   <asp:GridView ID="dgAssociatedAttributes" runat="server" AutoGenerateColumns="False" BackColor="White" BorderColor="#999999" BorderStyle="None" BorderWidth="1px" CellPadding="3" GridLines="Vertical" Width="80%"> <FooterStyle BackColor="#CCCCCC" ForeColor="Black" /> <RowStyle BackColor="#EEEEEE" ForeColor="Black" /> <Columns>           <asp:Bound...

Multiple grid rows per Data row in GridView
I have a dataset that is binded to a gridview. The dataset has 5 fields and a description. I want to display 1 row for the 5 short fields and 1 row underneath it for the description. (per record)   For example: ID Name  Surname Field3 Field 4 1   John     Smith      blah    blah     This is the long description for  John Smith spanning 5 cells 2   Peter    Parker     blah    blah     This is t...

Web resources about - Accessing GridView Data Row By Row -

Highest Percentage Of Opera Mini Users Accessing Facebook? Macau
If you were asked to guess which country had the highest percentage of users of Opera mobile Web browser Opera Mini users accessing Facebook ...

International Users Accessing Facebook Places Through US VPN Accounts
By using a virtual private network (VPN) hosted in the United States, Facebook users from around the world are accessing Facebook Places. The ...

What are some alternatives to Yodlee for accessing bank information?
Clay Loveless , Founder, Jexy. Co-founder, Mashery. Founder, Jexy. Co-founder, Mashery.

Cloud Console - Accessing files in cloud storage for iPad on the iTunes App Store
Get Cloud Console - Accessing files in cloud storage on the App Store. See screenshots and ratings, and read customer reviews.

Meryl Streep On Accessing The Characters Within - YouTube
Meryl Streep talks about the importance of an actors work representing their ability. CONNECT WITH AFI: ...

Student pleads guilty to accessing records about Frances Abbott design scholarship
The Sydney student who leaked information about a fashion school scholarship controversially awarded to the daughter of the Prime Minister has ...

Accessing a headline opinion
Accessing a headline opinion

Sharp increase in authorities accessing private data
Australian law enforcement and government agencies have sharply increased their access without warrant to vast quantities of private telephone ...

Former librarian charged with accessing student records of Frances Abbott
A former part-time librarian at a Sydney design school has been charged after she allegedly accessed student records of Prime Minister Tony Abbott's ...

Frances Abbott scholarship: Sydney woman pleads guilty to accessing Whitehouse Institute records on PM's ...
A Sydney woman who leaked the student records of Tony Abbott's daughter pleads guilty. A Sydney woman who leaked the student records of Prime ...

Resources last updated: 1/23/2016 9:34:52 PM