nakor77 21 Junior Poster in Training

are you using the SelectedValue property or the SelectedItem.Text property?

nakor77 21 Junior Poster in Training

Set the autogeneratecolumns property to false

nakor77 21 Junior Poster in Training

Be sure that in the page load event you put the databinding of the gridview in a !IsPostBack block. Right now the values in the gridview are getting reset before the button's click event is executed because the page load event occurs before the click event during a postback.

sandesh.ps.9 commented: Thank You. This helped +0
nakor77 21 Junior Poster in Training

If I understand what you're asking correctly then this is how I' would probably go about implementing it. I'd start it with a form for a single row and have a button that the user can click to add additional rows. Use a PlaceHolder control and add the new controls inside of it. This way you can dynamically add as many rows as needed by the user. When they submit the form you can loop through the PlaceHolder's controls property to get all of the controls that the user entered.

nakor77 21 Junior Poster in Training

Can you provide the code for the GridView, where you're databinding it, and the code where you're trying to get the radio button values?

nakor77 21 Junior Poster in Training

The Music Store is a pretty decent introduction to MVC

nakor77 21 Junior Poster in Training

It's almost always a good idea to maintain a separation of concerns. It generally makes the troubleshooting process easier. If you need to change your data access you should be able to update your data access layer and not make changes to the rest of your application. The same he's for any other logical layers your application may include.

nakor77 21 Junior Poster in Training

You would use one of the other methods by passing it the parameter types that it expects. If you want to use the method that takes two integers, then pass it two integers. If you want to use the method that takes two doubles, then pass it two doubles. The types of the parameters will determine which of the methods gets called.

nakor77 21 Junior Poster in Training

What kind of template are you talking about? Is this for some sort of content management system or something else?

nakor77 21 Junior Poster in Training

The query string is what gets passed at the end of the url. If the page url is "http://www.mywebsite.com/index.aspx?id=123" then there is a query string with a key of "id" and a value of "123". It's useful for telling a page to load specific information. It's scope is just for that specific request.

nakor77 21 Junior Poster in Training

are you creating any of these controls dynamically or are they all defined on the .aspx page? With the MultiView all of the controls are present on the page that are defined in the view. It should just be a matter of accessing it like any other control. TextBox1.Text or DropDownList1.SelectedValue, for example.

nakor77 21 Junior Poster in Training

Have you defined the EditTemplate in the ListView? Providing some code would probably help so we can see what's going on. Are you getting any errors?

nakor77 21 Junior Poster in Training

I understand, just wanted to make sure. Have a look at this and see if it helps.

nakor77 21 Junior Poster in Training

Shouldn't the controls in the UpdatePanel be inside of a <ContentTemplate> tag?

nakor77 21 Junior Poster in Training

What are the errors you are getting? Can you provide the code for the edit event?

nakor77 21 Junior Poster in Training

You can use the template field as suggested by JorgeM. If you use the AjaxControlToolkit then you could use the FilteredTextBoxExtender to limit what the user is able to enter.

Regardless of how you handle it on the client side you should always validate the input on the server side since it is possible for users to change what is being sent to the server between the time when it's validated on the client side and when it actually gets sent.

A gridview column often is just made of BoundFields and looks similar to

<Columns>
    <asp:BoundField DataField="ColumnOne" SortField="ColumnField" />
</Columns

When using a template field that would instead look like

<Columns>
    <asp:TemplateField HeaderText="Column One" SortField="ColumnOne">
        <ItemTemplate>
            <asp:Label ID="label_ColumnOne" runat="server" Text='<%# Eval("ColumnOne") %>' />
        </ItemTemplate>
        <EditItemTemplate>
            <asp:TextBox ID="textbox_ColumnOne" runat="server" Text='<%# Bind("ColumnOne") %>'></asp:TextBox>
        </EditItemTemplate>
    </asp:TemplateField>
</Columns>

The ItemTemplate is what is displayed by default. The EditItemTemplate gets displayed when you select "edit" for that row. You can add as many controls into a template field as makes sense for your need. So you can add a validator control to the textbox, or a filter control, or whatever.

Here's a link for a tutorial on Using TemplateFields In The GridView Control

nakor77 21 Junior Poster in Training

How are you loading the data for your listview? Are you going to be using a datasource control, such as a SqlDataSource or EntityDataSource? Or are you going to be setting the datasource in your code behind somewhere? Will the ListView always display the same columns? It would help some to see what code you have so far and maybe someone could point out where you're going wrong.

nakor77 21 Junior Poster in Training

If you're using .net 4.0 or later you can create default values for your parameters

public static void Feed(string Food="Unknown")
{
    if (Food != "Unknown")
    Console.WriteLine("{0} eats some {1}.", Name, Food);
}
nakor77 21 Junior Poster in Training

You're lblVehicleNr label is only available inside the ItemTemplate, not in the EditItemTemplate. If you run the debugger and step through your code you'll most likely find that the ValueToSelect variable is not getting set to a value. So then you're attempting to set the selected value to an empty string, which doesn't exist.

nakor77 21 Junior Poster in Training

post your updated code

nakor77 21 Junior Poster in Training

Sorry about that, missed the part where you said the drop down was inside the gridview.

if (ddl != null)
{
    ddl.SelectedValue = ddl.DataValueField;
    ddl.DataBind();
}

There's two reasons why this won't work. First, you need to databind the drop down before you set the selected value, otherwise there's nothing to select. Second, right now your telling it to set it's selected value to the string "VehicleID" instead of an actual vehicle id. You will need to get the vehicle id for the current row and set the selectedvalue to that.

Quick example:

string authorID = (row.Cells[1].Controls[0] as TextBox).Text; // Get the primary key for the row

DropDownList ddl = row.FindControl("ddlState") as DropDownList; // Get the drop down list

if (ddl.Items.Count <= 1) // if the drop down is empty or only has default item
{
    ddl.DataSource = GetStateList();
    ddl.DataBind();
}

ddl.SelectedValue = GetStateByAuthorID(authorID); // gets the state for the current row's author

You might need to use a different cell index and control index to get the primary key for your row depending on which column it's in. If you are not including the key in the row and you have the DataKeyNames property of the gridview set then you could use that to get the key

string key = MyGridView.DataKeys[row.RowIndex].Value.ToString();
nakor77 21 Junior Poster in Training

I notice your dropdownlist doesn't have a datasourceid set so I'm going to guess you're databinding your dropdownlist inside the page load as well. Make sure to put that databinding inside of a !IsPostBack block, otherwise your dropdownlist gets repopulated on every postback which will cause the selected value to reset, which is what appears to be happening here

if (!IsPostBack)
{
    //databind dropdownlist
}
nakor77 21 Junior Poster in Training

Here's a link for using multiple membership providers:

http://stackoverflow.com/questions/5342158/using-multiple-membership-providers-within-asp-net-mvc-3-application

if you want to give that a try

nakor77 21 Junior Poster in Training

why not use the same membership database for both applications?

nakor77 21 Junior Poster in Training

I believe the default timeout for session is 20 minutes, but you can modify that in your web.config if you need to specify a different time span. Also, a note on hericles suggestion, the session_end event is available when using InProc session storage. This is the default option so unless you've specified a different type of session storage, such as state server or sql server, this is what you're using.

nakor77 21 Junior Poster in Training

move the code that sets your textbox values into its own method. Call that method from the page_load event but put it inside an "If IsPostBack" so that it's only called when the page initially loads and not on each postback after that. Also call that method at the end of your update button's click event.

Basically what is happening right now is that that the page load event is being called before the button's click event executes so it is refreshing the data in the textboxes to their original values and updating the data in the database with those values rather than the data that was entered into the textboxes but the user.

If you google "msdn ASP.NET page event life cycle" you should be able to find some more in depth information on how the page event life cycle works for asp.net.

JorgeM commented: good response +6
nakor77 21 Junior Poster in Training

Have you set a breakpoint and debugged it?

nakor77 21 Junior Poster in Training

Also, the control you are getting the City value from is a DropDownList, not a TextBox

nakor77 21 Junior Poster in Training

It would probably be best to just not include that column at all if possible. Something like

for (int rowNo = 0; rowNo < noOfRows; rowNo++)
{
    for (int columnNo = 0; columnNo < noOfColumns; columnNo++)
    {
        if (columnNo != 2) // or whichever index you want to leave out.
        {
        // rest of code

might work. If the gridview already has columns defined you may need to clear them.

nakor77 21 Junior Poster in Training

might need to see more of the code than just that one line. That doesn't really tell anyone what is going on.

nakor77 21 Junior Poster in Training

You could create a page property using Session to maintain its value

public bool NewUser
{
  get
  {
    return Session["NewUser"] == null ? true : (bool)Session["NewUser"];
  }
  set
  {
    Session["NewUser"] = value;
  }
}

This is C# though, not real sure of the syntax in VB. In this instance if the Session is null then it will return true if the Session variable is not null then it casts it as bool and returns the value.

This page contains some information about using Session

nakor77 21 Junior Poster in Training

If you are using a view for your data source and want to perform an update that will affect multiple tables then it would probably be best to use the GridView's OnUpdating event to get the values and update each table individually.

nakor77 21 Junior Poster in Training

If NewUser is just a property of the page then it will always be reset each time the page is called because the page is recreated each time. You should probably look into asp.net Sessions to store the value of NewUser, that way the updated value will persist across postbacks.

nakor77 21 Junior Poster in Training

you can't directly set properties from control event handlers. They have to point to methods.

nakor77 21 Junior Poster in Training

you don't need the <td> tags inside an itemtemplate. The gridview's itemtemplate should generate them automatically. Not sure that is what is causing you're problem or not though. Maybe you could post a screenshot or something so we can better tell what it's doing.

nakor77 21 Junior Poster in Training

have you added a reference to those other projects?

nakor77 21 Junior Poster in Training

yes, there must be a space, but the code you provided is missing one. The code I pasted was a snippet from the code you provided, if you look you'll notice it's missing a space before the WHERE. I wasn't telling you that there shouldn't be a space, I was telling you that you don't currently have a space between those two words

nakor77 21 Junior Poster in Training
string query = "SELECT departure_date, airport_location, seat_capacity,    origin_airport_code, destination_airport_code FROM Flight_Schedule, Airport, Travel_Class_Capacity";
 
                query += "WHERE airport_location.Airport= '" + arrAirport + "' AND airport_location.Airport='" + depAirport + "' AND departure_date.Flight_Schedule='" + depDate + "' AND ";

There's no space between "Travel_Class_Capacity" and "Where"

nakor77 21 Junior Poster in Training

where are you setting the gridview's datasource?

nakor77 21 Junior Poster in Training

I don't see an "Insert into" statement in any of the code you posted. Could you post the full error message. It should also provide you with the line number where the error is occurring. Also have you tried walking through it in debug mode to see where the error occurs at?

nakor77 21 Junior Poster in Training

Line 37 above: Where is dollarAmount coming from?

Also your Converter class has no property or field for dollarAmount, so Line 41 will cause an error as well since you can't set a property that doesn't exist. Same thing when trying to use convert.breakdown, it doesn't exist in the Converter class

nakor77 21 Junior Poster in Training

if you know for sure that textbox40.Text is a numeric value then it would probably help to post the code for check.PostalCodeChecking() to see what's going on inside that method. But you really should create an int variable and set it to the value of TextBox40 and then pass that variable into the method. It provides for better error checking. Also, do you really have 40 TextBoxes labeled as TextBox1, TextBox2, etc? If so you should really look into naming your controls with meaningful names, something that gives a hint of what the control is being used for. It makes debugging and maintaining your applications a lot simpler.

nakor77 21 Junior Poster in Training

you should have a web.config in the root directory of the website you're making. This is a separate file from your webforms.

nakor77 21 Junior Poster in Training

If the number is always the last character and is only a single digit you could do something like this

int i = 0;

if (int.TryParse(command.Last().ToString(), out i))
{

}

If there's a chance that command might be empty then you'd want to check for that before trying to call int.TryParse on it

You could also use command.First() to get the char value of the first character in the string. You'll need to add a "using System.Linq" for these methods if you don't already have it.

ddanbe commented: Not Bad! +14
nakor77 21 Junior Poster in Training

if Variables inherited from Methods then that would work. However if Methods inherits from Variables then you would need to cast v as a Methods type.

Methods m = (Methods)v;

If neither inherit from the other then this will not work.

nakor77 21 Junior Poster in Training

Often an example can do more to explain than an explanation. I tried to comment the example to explain what is going on as much as possible.

public class Parent
    {
        // public properties
        public int X { get; set; }
        public int Y { get; set; }

        // protected properties
        protected int Z { get { return 75; } }

        // private properties
        private int W { get { return 0; } }
    }

    public class Child : Parent
    {
        // the child object has access to protected properties
        public int Z { get { return base.Z; } }

        // This causes an error because private
        // properties are not accessible outside
        // of the class in which they are created
        public int W { get { return base.W; } }
    }

An example of using these classes in a simple console app

// Create a new child object and set its X and Y values
            Child child = new Child();
            child.X = 25;
            child.Y = 50;

            Console.WriteLine("child.X: " + child.X);
            Console.WriteLine("child.Y: " + child.Y);

            // A parent object can be created directly 
            // from an instance of a Child object
            Parent parent = child;
            Console.WriteLine("parent.X: " + parent.X);
            Console.WriteLine("parent.Y: " + parent.Y);
            
            // This will cause an error since Z is protected
            // it is only accessible by the class and classes
            // that inherit from it
            Console.WriteLine("parent.Z: " + parent.Z);

            // This will cause an error because W is private
            // and only accessible within …
nakor77 21 Junior Poster in Training

you might try replacing localhost with 127.0.0.1

You might also try going through the MySQL Causes of Access Denied Errors page.