Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8816493
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T04:38:05+00:00 2026-06-14T04:38:05+00:00

I try to write data grid in aspx. In my database there is a

  • 0

I try to write data grid in aspx. In my database there is a column which name is ‘PROJECT_NAME’. I want these columns in my data grid, then I add second column (editbox) to add values every each of project. This is all in grid view, and I add button in form. When I press the button how can I understand which columns value belong which project?

I mean, for example

  1. Row value : A project 2 Column value : 50
  2. Row value : B project 2 Column value : 60
  3. Row value : C project 2 Column value : 70

I want to know when I press button 1. project value 50 how can ı understand this?

This is my 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></title>
        <style type="text/css">
            .style1
            {
                width: 78px;
            }
            .style2
            {
            width: 426px;
        }
    </style>
</head>


<body>
    <form id="form1" runat="server">
    <div style="height: 561px">

        <table style="width: 100%; height: 556px;">
            <tr>
                <td>
                    &nbsp;</td>
                <td>

                    <table style="width:100%;">
                        <tr>
                            <td class="style1">
                                Ay</td>
                            <td>
                                <asp:TextBox ID="ay" runat="server"></asp:TextBox>
                            </td>
                            <td>
                                &nbsp;</td>
                        </tr>
                        <tr>
                            <td class="style1">
                                Yıl</td>
                            <td>
                                <asp:TextBox ID="yil" runat="server"></asp:TextBox>
                            </td>
                            <td>
                                &nbsp;</td>
                        </tr>
                        <tr>
                            <td class="style1">
                                &nbsp;</td>
                            <td>
                                &nbsp;</td>
                            <td>
                                &nbsp;</td>
                        </tr>
                    </table>
                </td>

                <td>
                    &nbsp;</td>
            </tr>
            <tr>
                <td>
                    &nbsp;</td>
                <td>
                   <asp:GridView ID="portföy" runat="server" 
                    CellPadding="3" GridLines="Horizontal" 
                    AutoGenerateColumns="False"      
                    DataKeyNames="PRJ_PROJECT_NAME" BackColor="White" BorderColor="#E7E7FF" 
                    BorderStyle="None" BorderWidth="1px" Font-Bold="False" Font-Names="Verdana" 
                    Font-Overline="False" Font-Size="Smaller" Width="1000px"  
                    >
                    <RowStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" />
            <Columns> 
            <asp:TemplateField HeaderText="PRJ_PROJECT_NAME"  HeaderStyle-HorizontalAlign="Left"> 

                <ItemTemplate> 
                    <asp:Label ID="lblProjeTT" runat="server" Text='<%# Bind("PRJ_PROJECT_NAME") %>'></asp:Label> 
                </ItemTemplate> 
                <HeaderStyle HorizontalAlign="Left"></HeaderStyle>
            </asp:TemplateField> 

            <asp:TemplateField HeaderText="Miktar (a/g)" HeaderStyle-HorizontalAlign="Center"> 

                <ItemTemplate> 
               <asp:TextBox runat="server" id="txtField1" Text='<%# Bind("TAMAMLANMA_YUZDESI") %>'/>
                </ItemTemplate>  
                <EditItemTemplate>
                 <asp:TextBox runat="server" id="txtField1" Text='<%# Bind("TAMAMLANMA_YUZDESI") %>'/>
                </EditItemTemplate>

                <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
            </asp:TemplateField>             
            <asp:TemplateField HeaderText="" ShowHeader="False" HeaderStyle-HorizontalAlign="Center"> 

                <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
            </asp:TemplateField> 
        </Columns> 
                    <FooterStyle BackColor="#B5C7DE" ForeColor="#4A3C8C" />
                    <PagerStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" HorizontalAlign="Right" />
                    <SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="#F7F7F7" />
                    <HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#F7F7F7" />
                    <EditRowStyle BackColor="#FFFFA8" ForeColor="Black" />
                    <AlternatingRowStyle BackColor="#F7F7F7" />
                </asp:GridView>

                    <table style="width:100%;">
                        <tr>
                            <td class="style2">
                                &nbsp;</td>
                            <td>
                                &nbsp;</td>
                            <td>
                                &nbsp;</td>
                        </tr>
                        <tr>
                            <td class="style2">
                                &nbsp;</td>
                            <td>
                                <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" 
                                    Width="149px" />
                            </td>
                            <td>
                                &nbsp;</td>
                        </tr>
                        <tr>
                            <td class="style2">
                                &nbsp;</td>
                            <td>
                                &nbsp;</td>
                            <td>
                                &nbsp;</td>
                        </tr>
                    </table>

                </td>
                <td>
                    &nbsp;</td>
            </tr>
            <tr>
                <td>
                    &nbsp;</td>
                <td>
                    &nbsp;</td>
                <td>
                    &nbsp;</td>
            </tr>
        </table>

    </div>
    </form>
</body>
</html>

This is my code:

    using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.OleDb;
using System.Data;
using System.Configuration;

public partial class _Default : System.Web.UI.Page
{
    csOra cOra;
    string oraTns = ConfigurationManager.AppSettings["TNS"];
    string oraUserName = ConfigurationManager.AppSettings["OraUserName"];
    string oraPassword = ConfigurationManager.AppSettings["OraPassword"];

    protected void Page_Load(object sender, EventArgs e)

    {

          cOra = new csOra(oraTns, oraUserName, oraPassword);
        if (cOra.OraCnn.State != ConnectionState.Open)
        {
            MessageBox.Show("Oracle ile bağlantı kurulamadı...");
            return;
        }
        try
        {
            if (!IsPostBack)
            { 

                setGrid();
            }

        }
        catch (OleDbException ex)
        {
            Response.Write(@"Oracle Error:" + ex.Message);
            return;
        }
        catch (Exception ex)
        {
            Response.Write(@"Error:" + ex.Message);
            return;
        }

    }

    void setGrid()
    {
        string sSQL = @"SELECT PRJ_PROJECT_NAME,TAMAMLANMA_YUZDESI
                        FROM  PPIGANTT.KOKTEYL_TABLE_3
                        WHERE PRJ_PROJECT_NAME like '%d%' 
                        ORDER BY Request_id";
        try
        {
            OleDbDataAdapter oDa = new OleDbDataAdapter(sSQL, cOra.OraCnn);
            DataTable portföy_ = new DataTable("KOKTEYL_TABLE_3");
            oDa.Fill(portföy_);

            if (portföy_.Rows.Count > 0)
            {
                portföy.DataSource = portföy_;
                portföy.DataBind();
            }
            else
            {
                portföy_.Rows.Add(portföy_.NewRow());
                portföy.DataSource = portföy_;
                portföy.DataBind();

                int TotalColumns = portföy.Rows[0].Cells.Count;
                portföy.Rows[0].Cells.Clear();
                portföy.Rows[0].Cells.Add(new TableCell());
                portföy.Rows[0].Cells[0].ColumnSpan = TotalColumns;
                portföy.Rows[0].Cells[0].Text = "No Record Found";
            }
        }
        catch (OleDbException ex)
        {
            Response.Write(@"Oracle Error:" + ex.Message);
            return;
        }
        catch (Exception ex)
        {
            Response.Write(@"Error:" + ex.Message);
            return;
        }
    }
    void UpdatePortföy(string Portföy, int bütçe    )
    {
        string sSQL = @"BEGIN UPDATE PPIGANTT.KOKTEYL_TABLE_3
                           SET TAMAMLANMA_YUZDESI = " + bütçe + @"WHERE PRJ_PROJECT_NAME ='"
                                         + Portföy + @"' ; COMMIT; END;";
        string sErr = "";
        try
        {
            cOra.ExecNonQuery(sSQL, out sErr);
        }
        //setGrid();
        catch (OleDbException ex)
        {
            Response.Write(@"Oracle Error:" + ex.Message);
            return;
        }
        catch (Exception ex)
        {
            Response.Write(@"Error:" + ex.Message);
            return;
        }
    }



    protected void Button1_Click(object sender, EventArgs e)
    {
       /*  what can I write here to understand whic column value ?*/
    } 
}

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T04:38:06+00:00Added an answer on June 14, 2026 at 4:38 am

    Inside of Button1_Click you need need to loop through all the rows in the GridView and do a FindControl on each row to get the label and textbox. From that you can determine what the PRJ_PROJECT_NAME and values in the textbox are.

    Here is an example:

    Default.aspx

    <asp:GridView ID="gvData" runat="server" AutoGenerateColumns="false">
      <Columns>
        <asp:TemplateField>
          <ItemTemplate>
            <asp:Label ID="lblLabel" runat="server" Text='<%# Bind("Number") %>' />
          </ItemTemplate>          
        </asp:TemplateField>
        <asp:TemplateField>
          <ItemTemplate>
            <asp:TextBox ID="txtData" runat="server" Text='<%# Bind("Value") %>' />
          </ItemTemplate>
        </asp:TemplateField>
      </Columns>
    </asp:GridView>
    <asp:Button ID="btnSubmit" runat="server" OnClick="btnSubmit_Click" Text="Submit" />
    

    Default.aspx.cs

    protected void Page_Load(object sender, EventArgs e)
    {
      if (!IsPostBack)
      {
        // Create some fake data and bind it to the gridview
        var data = new List<TheData>();
    
        foreach(var num in Enumerable.Range(1, 4))
        {
          var newData = new TheData();
    
          newData.Number = num.ToString();
          newData.Value = num;
    
          data.Add(newData);
        }
    
        gvData.DataSource = data;
        gvData.DataBind();
      }
    }
    
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
      for (var index = 0; index < gvData.Rows.Count; ++index)
      {
        var row = gvData.Rows[index];
        var lblLabel = row.FindControl("lblLabel") as Label;
        var txtData = row.FindControl("txtData") as TextBox;
    
        //Here is where the values are grabbed, at this point you can do what you need to.
        var number = lblLabel.Text;
        var value = txtData.Text;
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I try to write a statement with Razor syntax that use mvccontrib grid where
I want to be able to reorder a rectangular grid of data into a
I have one one Grid which contain 4 column and somewhere column contain TextField
try to write a composite component that allows mutltiple text inputs. I read that
I try to write Activator action for changing current song rating. I now that
I try to write a Facebook app. This app will communicate with a rfid
I try to write a javascript Self-Executing Anonymous Function window.App = window.App || {}
I try to write DSL class Warcraft class << self def config unless @instance
I try to write a macro in clojure that sets up a namespace and
I try to write a simple user script to enlarge the picture when you

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.