GridView (ASP.net)

Capodecina
Permabanned
Joined
31 Dec 2003
Posts
5,172
Location
Barrow-In-Furness
How can I limit the size of the GridView when Editing? It expands to a stupid size and breaks my website :(

I've tried changing the width in the EditRowSize properties but it does nothing.

Also looking for some advice on what i'm doing.

Since you can't input data using the GridView but I would like an input section that pretty much resembles the way it's layed out, I was going to create a button which generates a new row in the database but with blank fields, then do an autopostback so the user can click edit and then add the values into the GridView.

Does that seem sensible or is there a better way?
 
Thanks :)

My only problem with using that is that I don't really understand what's going on in the VB code part (i'm new to this). So I feel like a spoon using it, plus there's no point in just stealing without understanding.
 
VB dude :)

Also does anyone know how I can validate the input into the GridView fields? I'll need it for editing and inputting.

I'm not sure if a GridView is the best option though, because ideally I need some fields to be drop down and populated from a list in the database?
 
Last edited:
Unfortunately creating a new blank row is quite complicated and uses some coding, the links posted are the only ways to do it AFAIK.

As for changing the size of the gridview when editing, the best way would be to click the arrow and open up the tasks for your gridview.
Select 'Edit Columns'.
Then for each field click the 'Convert to TemplateField' link.

Close this window, and open the 'Edit Templates' window.
Using the dropdown select a fields insert or edit template, then change the size of the textbox.
Do this for each field.

Converting Columns to Template will also allow you to add your dropdown lists, just remove the textbox and replace with a dropdown list.

Another suggestion would be to change the font-size as well.
 
Last edited:
I'll just have to give it a go Kevin I think. I've sorted limiting the size thank you very much :D

As for the drop down lists. I'm a little confused as to what to do.

Ideally i'd like to be able to present it like a gridview, but when I click edit it shows a drop down box (populated from a database) that allows the user to select a value from the list, and then submit the value they have selected. It should show the value they have selected when being presented in the GridView.

For example, selecting a project code from a Projects table, but submitting it to a different table to be stored.

Thanks for the help.
 
So you want to display a drop down list in the gridview and store whatever is in the drop down list to a new table?

Well for starters, if you followed through what I posted before on using templates, you should be able to access each individual field in your gridview for editing.

Once you access the insert template, you can remove the textbox it automatically sets, and replace it with a drop down list.
Then simply create a new datasource underneath for your drop down list, with the required select, insert and update sql statements for the other table.
 
I don't want it in a new table. I'll try explain what i'm trying to achieve a little better.

Developing a system that will capture hours people have spent doing something based on a list of tasks. For example:

ID TASK DATE MON TUE WED THU FRI
----------------------------------------------------------
1 001231 10/07/88 1.5 6 6 3 10
2 002222 10/07/88 8.0 7 4 7 10
3 004213 13/07/88 1.5 6 4 7 10



I'd like the task to be a down down list, populated from data in another table. With all of the data shown above stored in its own table along with a UserID (for who submitted it). I'm not sure if there's a better way of doing it.

If I added the drop down list in the way you said, would I have to change the Update command the GridView uses to add the value selected in the drop down box when it's selected?

I'm new to this so sorry if i'm not explaining myself too well, I have only just started learning. I do appreciate the help though.
 
OK, it would be straight forward to do that for updating the existing row, but because a gridview doesn't allow inserts you would need the code posted before to create a dummy row containing a drop down list.
It's possible, but requires some coding.

To add a drop down list in the gridview for updating, access the edit template for the task field in the gridview.
Delete the textbox, and add a drop down list.
Create a new datasource.
Select/Create your select statement.
Assign the datasource to your drop down list.

That's it.

Btw, which web page editor are you using to create these pages?
 
I'm not scared of coding don't worry, just looking for a point in the right direction and checking to make sure i'm on the right path :D

I'll give it a go and let you know thank you :)

I'm using VWD.
 
Wardie said:
I'm using VWD

Phew, didn't know if you were typing all the code out in Dreamweaver or something. :eek::cool::D

Wardie said:
I'm not scared of coding don't worry, just looking for a point in the right direction and checking to make sure i'm on the right path :D

Just run through the tutorials and videos on ASP.NET, they are a great help.
I only starting learning ASP.NET about 6 months ago, and I have managed to grasp the basics.
I did a bit of VB/VBA at college so picking it up wasn't too difficult, but there is still a lot for me to learn.
 
Back
Top Bottom