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

If I had to guess I'd say it's most likely a permission issue. You have the right privileges to access those network location which is why it works when you run it, but your server that's running the application doesn't.

nakor77 21 Junior Poster in Training
You haven't really provided enough information for anyone to help you with. If you're using some sort of content management system for your site you might should contact their support (if they have one) to see if there are some common issues that might be causing your problem. If it's a problem with the web server then you need to contact your hosting provider to see if anything can be done.
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

What error are you getting?

nakor77 21 Junior Poster in Training

Generally speaking, trying to access the content page from the master page is a pretty backwards way of doing something. If you have multiple content pages are they all going to implement this behavior? It would be easier, and make more sense, to put the user control into the content pages rather than putting the user control into the master page. This way you can include it only in the pages that would need it since most like not every content page would use it. Then you can access the content page through the "Page" property of the user control.

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

Another tutorial

http://www.codeproject.com/Articles/8477/Using-ADO-NET-for-beginners

You can also google ADO.Net to find more, there's a lot out there

nakor77 21 Junior Poster in Training

why not use the same membership database for both applications?

nakor77 21 Junior Poster in Training

http://www.asp.net has all sorts of tutorials for gettings started with asp.net, including how to connect to the database. Do you have a more specific question or problem?

nakor77 21 Junior Poster in Training

Is the process you use exactly the same for every image or does it handle different file types in different ways? (jpg, png, bmp, etc.) Hard to really know what's going on without having any code to look at.

nakor77 21 Junior Poster in Training

in this example myInterface is just a blank interface. Every class that gets returned implements the interface, just as in your code all 3 of your storage providers must implement IStorageProvider. In the code I provided you should be able to swap out my "myInterface" with "IStorageProvider", and swap out your classes for the example classes I used. It should work fine as long as all of your classes implement IStorageProvider, which it looks like they do from your code.

nakor77 21 Junior Poster in Training

You could make use of generics.

    class MyInterfaceFactory
    {
        public static T GetClass<T>() where T : myInterface
        {
            myInterface temp = null;

            if (typeof(T) == typeof(ClassOne)) temp = new ClassOne();
            else if (typeof(T) == typeof(ClassTwo)) temp = new ClassTwo();
            else if (typeof(T) == typeof(ClassThree)) temp = new ClassThree();

            return (T)temp;
        }
    }

This is a pretty simple example, you should be able to implement it with your interface and classes fairly easily I think.

DrMAF commented: what does myInterface contain?? what is the implementation of ClassOne, for example?? +0
nakor77 21 Junior Poster in Training

I'd start out by going through the tutorials on http://www.asp.net

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

DataBinding(dataBinding => dataBinding.Ajax().Select("_EmployeesHierarchyAjax", "Grid"))

The "Grid" in that line is specifying the name of the controller to look for the action in.

nakor77 21 Junior Poster in Training

Can you also post the code for your layout page, should be int eh views/shared folder. Also, just to be sure, the name of your controller is GridController?

nakor77 21 Junior Poster in Training

I've gone through several of the tutorials on the asp.net/mvc site and not had a problem. Is there a specific issue you're having problems with?

nakor77 21 Junior Poster in Training

you don't get an exe from web applications, the code gets compiled into .dll files which are deployed to the IIS web server. If you want to ensure your connection string is kept safe, then, ideally, you should have your connection string information in your web.config file and then you would encrypt it before deploying it to the server. If you google "encrypt web.config connectionstring" you'll find all sorts of posts out there on how to do this. I prefer to use the Microsoft Enterprise Library to do this as their tool makes it very easy.

nakor77 21 Junior Poster in Training

You're question is pretty vague and leaves a lot to interpretation. Is there a specific problem you are having or are you just wanting someone to hold your hand through making an entire web application?

nakor77 21 Junior Poster in Training

If it's not showing the data then the configuration is probable not quite as "well" as it needs to be. But without any code it's going to be impossible for anyone to help you.

nakor77 21 Junior Poster in Training

Make sure you have the latest versions of jquery, jquery.validate, and modernizr if you're using them. Some of the older versions will cause telerik to break.

in the code they passe new GridModel(employees)
but this object is not catch in the view.
then how data is catch

When the action is marked with the GridAction attribute it returns the GridModel as a JSON object that is used to update the contents of the telerik grid. Since you are using Ajax databinding this is done with an Ajax call to the server.

nakor77 21 Junior Poster in Training

There's really not a feasible way to demonstrate an entire n-tier architecture with code in a forum post. It generally consists of multiple projects targeting specific concerns of the application. You could do some research on the Model-View-Controller(MVC) pattern, the Model-View-ViewModel(MVVM) pattern, or the Model-View-Presenter(MVP) pattern to get yourself started.

nakor77 21 Junior Poster in Training

ok, so what exactly is the question? I understand what you're wanting to accomplish, but where are you in the process? What have you tried so far? What are your results compared to what you expect? Are you getting any errors?

nakor77 21 Junior Poster in Training
DateTime.Now.Hour

should do the trick

nakor77 21 Junior Poster in Training

what part are you confused about? If you know nothing at all about asp.net then I would recommend getting a good book on the subject or, even better, take a class if any are available in your area.

nakor77 21 Junior Poster in Training

The gridview, when paging is being used, does not load all data from the database at once. It only loads what is currently being displayed. So the data you selected on any previous page no longer exists as far as the GridView is concerned. If you want to update data across multiple pages you are going to need to store the data that has been selected in some way, most likely in a session variable. Then when you make the actual update you'll use the data from the Session variable rather than from the GridView.

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

You can't access ListView2 from the item template because it doesn't exist in the item template. What exactly are you trying to do in the ItemTemplate that you are needing to access ListView2 for? I couldn't quite make out what your goal is from your post.

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

Ok, I'll try to walk through a quick example for you. I've created a page that has two button controls, a Panel and a label. What it's going to do is on the click of the first button there will be 5 dropdownlists added to the panel. On the second button click it will get the values from those dropdownlists and display them all in the label. The first thing I need to do is to have a way to know how many dropdownlists I have created. In order to do this I will create a property that saves that count in viewstate.

public int DDLCount
{
    get
    {
        // Try to get an instance of the DDLCount ViewState object
        object temp = ViewState["DDLCount"];
        // If temp is not null then cast it to int and return it,
        // otherwise return 0
        return temp == null ? 0 : (int)temp;
    }
    set { ViewState["DDLCount"] = value; }
}

Next I'll create a method to add the dropdownlists to the page.

private void CreateDropDownLists()
        {
            // This is just to set the count to a default value
            // You may possibly need to generate the count of dropdownlists
            // in some other manner, depending on your project
            if (DDLCount == 0)
                DDLCount = 5;

            
            for (int i = 0; i < DDLCount; i++)
            {
                // Create the dropdownlists
                DropDownList ddl = new DropDownList();
                ddl.ID = "Text_" + i;
                ddl.Items.Add(new ListItem("TestText_" + i, "TestValue_" + i));

                // Add it to the panel …
goltu commented: Good knowledge of programming +0
nakor77 21 Junior Poster in Training

The problem is probably that you're dropdownlist controls are not being rebuilt when the page loads. Before the second button's event gets fired the page will attempt to reload the page using the values saved in viewstate, because you are adding these controls dynamically they will not be available in viewstate. One option you might try is to maintain a count of the controls you add to the panel using a session variable or storing the count in a hidden control. Then during page_load add that number of dropdowns back into the panel.

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

have you tried setting the UpdateMode property for each of the UpdatePanels to conditional?

<asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">

The default mode is "Always" which will cause each update panel to also update any other update panels on the page. If you want the update panels to work independently then they need to be set to "Conditional"

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're closing your connection after you execute the first query.

nakor77 21 Junior Poster in Training

Then you should be able to use the GridView's OnUpdating event. This event occurs just before the data is sent to the database to be updated. The method will look something like

protected void GridView_OnUpdating(object sender, GridViewUpdateEventArgs e)
{

}

in the code behind. The parameter "e" will have two properties that you should be able to use. One called NewValues and one called OldValues.

protected void GridView_OnUpdating(object sender, GridViewUpdateEventArgs e)
{
    string value = e.NewValues["column_name"].ToString(); // would get one of the updated values

    string old = e.OldValues["column_name"].ToString(); // would get the original value
}
nakor77 21 Junior Poster in Training

are you trying to get the values before the gridview switches to edit mode or do you need to get the values before applying any updates to to the data? Say you click edit, now you get some input controls, you change a couple of values, then click update. Are you wanting the old values before the edit or before the update?

nakor77 21 Junior Poster in Training

First if the column in the database only takes two values, one that indicates true and one that indicates false then you should really be using bit for the data type. 1 would be approved and 0 would be unapproved. Then you're gridview would automatically use a checkbox field for that column and you could save yourself extra work. However if that's not going to be something you can change then you're probably going to want to look into using the GridView's RowDataBound event to do this.

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

The problem is going to most likely be caused because of viewstate. You are updating the text of the button on the client side which does not update the page's viewstate. When the postback occurs and the page fetches the viewstate data it will not see the updated text value for that button. One option you might try is to add a HiddenField control to the page and set it's value to "Update" in the select function of the autocomplete as well as the submit buttons text value. Then in the code behind access the hiddenfield value instead of trying to read the button's text value.

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

can you insert a null value into a column that doesn't allow nulls? I would guess not. You could possibly create some default value to insert that isn't likely to be a value chosen/used by whoever is filling out the form.

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

It really comes down to the lifespan of the data you're needing to keep track of. If you only need the data for the lifespan of the application then you can probably just keep it in memory via class properties, but if you need to persist the data then you'll need to make use of xml, database or some other storage medium.

nakor77 21 Junior Poster in Training

what have you tried so far? what kind of errors are you getting?