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

  • Home
  • SEARCH
  • 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 8910059
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T03:35:37+00:00 2026-06-15T03:35:37+00:00

Depending on whichh button is pressed I have to take the excursion_date_id which I

  • 0

Depending on whichh button is pressed I have to take the excursion_date_id which I will need in the next form!

SO what is best to use – buttonfield property maybe!

here is my code

First it’s the Dates.class

public class Dates
   {
        private int excursionID;
        private DateTime startdates;
        private double prices;
    public  int ExcursionID
    {
        get { return excursionID; }
        set { excursionID = value; }

    }
    public DateTime StartDates
    {
        get { return startdates; }
        set { startdates = value; }

   }

    public  double Prices
    {
        get { return prices; }
        set { prices = value; }
    }


    public Dates()
    { }


   }

}

Then I populate the gridview with the dates from my database
I want to have a button with text property “reserve” at the end of each row of the gridview!

protected void Page_Load(object sender, EventArgs e)
        {
           string excursionnId = Request.QueryString["ExcursionId"];


        Dates date = new Dates();
        List<Dates> listDate = new List<Dates>();
        listDate = GetDates();
        gvDates.DataSource = listDate;
        gvDates.DataBind();

    }

    public List<Dates> GetDates()
    {
        List<Dates> datesList = new List<Dates>();

        string connectionString = "Server=localhost\\SQLEXPRESS;Database=EXCURSIONSDATABASE;Trusted_Connection=true";
        string excursionnID = Request.QueryString["ExcursionID"];
        string query =
    "SELECT Excursion_date_ID, Excursion_ID, Start_date, Price FROM EXCURSION_DATES WHERE EXCURSION_ID='" + excursionnID + "'";
        SqlConnection conn = new SqlConnection(connectionString);
        SqlCommand cmd = new SqlCommand(query, conn);
        try
        {
            conn.Open();
            SqlDataReader rd = cmd.ExecuteReader();
            int s=0;
            while (rd.Read())
            {
                Dates dates = new Dates();

                dates.ExcursionID = Convert.ToInt32(rd["Excursion_ID"]);
                dates.StartDates = Convert.ToDateTime(rd["Start_date"]);
                dates.Prices = Convert.ToDouble(rd["Price"]);
                datesList.Add(dates);

            }
        }
        catch (Exception EX)
        {

        }
        return datesList;
    }
}
  • 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-15T03:35:39+00:00Added an answer on June 15, 2026 at 3:35 am
     <asp:GridView ID="gvDates" runat="server" Width="100%" AutoGenerateColumns="false"  
                        OnRowCommand="grd_RowCommand" >
                        <Columns>
                            <asp:TemplateField>
                                  <ItemTemplate>
                                     <asp:Button ID="btn" CausesValidation="false"    CommandName="YourCommandName" 
                             CommandArgument='<%#Eval("Excursion_ID") %>' runat="server" Text="Text" />
    
                                  </ItemTemplate>
                            </asp:TemplateField>
                        </Columns>
                    </asp:GridView> 
    protected void grd_RowCommand(object sender, GridViewCommandEventArgs e)
        {
    
            string number = (string)e.CommandArgument;
            if (number==null) return;
            switch (e.CommandName)
            {
              case "YourCommandName":
                    Load(number);
                    break;
    
            // some others command
             }
        }
    

    OR without rowcommand

     <asp:GridView ID="gvDates" runat="server" Width="100%" AutoGenerateColumns="false"  >
                    <Columns>
                        <asp:TemplateField>
                              <ItemTemplate>
                                 <asp:Button ID="btn" CausesValidation="false"     OnClick="btnClick" 
                         CommandArgument='<%#Eval("Excursion_ID") %>' runat="server"  Text="Text" />
    
                              </ItemTemplate>
                        </asp:TemplateField>
                    </Columns>
                </asp:GridView> 
    protected void btnClick(object sender, EventArgs e)
    {
        Button btn=(Button)sender;
        if(btn==null) return;
        string number = (string)btn.CommandArgument;
        if (number==null) return;
    
        Load(number);
    
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form with 2 buttons, that depending on which is selected will
I have a group of three radio buttons. Depending on which radio button is
I have a web form that has 2 radio buttons, depending on which one
I have a combobox from which i need to programmatically disable items depending on
I have page where I use model which can have different types (depending by
I need to implement a scroll view which (on a button press) will page
My php script directs to a url depending on which submit button was pressed.
I have an application that will load a couple of windows depending on which
I have got two buttons, which both submit a form in asp.net. I need
I'm using the following code to load some sounds depending on which button a

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.