500 Points: Datagrid Help

Hi All,

I have created a datagrid that pulls in 5 different columns (read only) from a sql table.  I need to add on three editable columns to that datagrid, and be able to edit all the editable textboxes at once, and then click update once.  I then need all eight fields to populate a new table.  Full code examples would be awesome!  A second piece of this puzzle that isn't necessary to answer but would be nice is when you click the update button only the information is thrown into an email and sent off to an administrator email.

Thank you,

Who is Participating?
moduloConnect With a Mentor Commented:
PAQed with points refunded (500)

Community Support Moderator
Following is a good example on how to create the editable datagrid:

URL: http://dotnetjunkies.com/Article/65DC168F-B2AD-408B-8AA0-AD90DD739317.dcik

To send the e-mail you can use the System.Web.Mail namespace.  Check it out here:

URL: www.systemwebmail.com

HTH, Nauman.
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

muliganAuthor Commented:
Let me check these out.  Thanks
muliganAuthor Commented:

Thanks for the links, but none of them do what I need well at least to the full extent.  I need to come up with a solution what would allow me to bring in 5 columns from table A (SQL) to a datagrid where those 5 columns are not editable.  But, I need to append 3 columns at the edit of the datagrid that are editable.  8 total columns.  I then need to allow the user to add new values to all the rows of the datagrid at once, and only have to click the update button once.  Once the button has been pressed, I need the 8 columns of information to be added to table B (SQL) where there was something added in the one of the three editable columns (no columns with nothing in the editable columns).  I then need to have that information email to an administrator.


i thnk u have a similar question posted in the .net section .. i have given samples on how u can do this .. pls check it ..
muliganAuthor Commented:

I have asked to to delete that question as it seemed to be dead, so I started this new question.  I read thru your sample, and I don't understand your VB sample.  Could you come up with a working example?  Maybe with the pubs database or something?

Sorry for the confusion,

Heya...my $0.02

sounds like perhaps you might need to dynamically create your datagrid.  it kinda would look someting like this in your code-behind:

(note: you'll need a placeHolder control too for this to work)

//create an object based on a dataGrid class
DataGrid myGrid = new DataGrid();

//set where to position your new grid
myGrid.Style["position"] = "ABSOLUTE";
myGrid.Style["Left"] = "20px";
myGrid.Style["Top"] = "150px";
myGrid.Width = System.Web.UI.WebControls.Unit.Percentage(80.00);

//make grid look pretty
myGrid.CellPadding = 1;
myGrid.GridLines = GridLines.Both;
myGrid.ForeColor = Color.Black;
myGrid.BackColor = Color.Beige;
myGrid.AlternatingItemStyle.BackColor = Color.Gainsboro;
myGrid.HeaderStyle.BackColor = Color.BlanchedAlmond;

//attach your event handler
myGrid.ItemCommand += new DataGridCommandEventHandler(dataGrid_ItemCommand);

myGrid.ItemDataBound += new DataGridItemEventHandler(myGrid_ItemDataBound);
myGrid.SelectedIndexChanged += new EventHandler(dataGrid_SelectedIndexChanged);
myGrid.EditCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.EditRecord);
myGrid.CancelCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.myGrid_Cancel);
myGrid.UpdateCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.myGrid_Update);

//important to set it to false
myGrid.AutoGenerateColumns = false;

//set it to a datasource of your choosing
myGrid.DataSource = (insert your datasource here)

//set the key field for the grid
myGrid.DataKeyField = "ManRequestID";

//create a column object that contains the edit button
EditCommandColumn editCol = new EditCommandColumn();
editCol.HeaderText = "Edit";
editCol.EditText = "Edit";
editCol.ButtonType = System.Web.UI.WebControls.ButtonColumnType.PushButton;
editCol.CancelText = "Cancel";
editCol.UpdateText = "Update";

//id from database
BoundColumn colID = new BoundColumn();
colID.DataField = "ID";
colID.ItemStyle.Width = System.Web.UI.WebControls.Unit.Pixel(5);
colID.HeaderText = "ID";

TemplateColumn tempPosition = new TemplateColumn();
tempPosition.HeaderText = "Position Name";
tempPosition.ItemTemplate = new GenericItem("PositionName");
//note: here I got a drop down list box, but could be substituted for a textbox
tempPosition.EditItemTemplate = new EditDropDownListItem("PositionName");


//add myGrid to placeholder


It’s not exactly what you had in mind…but hopefully should be enough to get you jump started…also…no time to check whether this works or not…but it should be pretty darn close
muliganAuthor Commented:

Sorry, My bad...I should have said.  I am not using Code Behind, I am using dreamweaver mx...I know...I know.  I will look into your example and try to pull what I can.


muliganAuthor Commented:
BTW.... I would like a vb.net solution
uhmm....never used dreamweaver...can't help you there....good luck though :)
muliganAuthor Commented:
Basically dreamweaver is the same, but there is just no code behind.
muliganAuthor Commented:
Still looking for help, if anyone is willing?
u will never get from anyone here a complete working sample written here .. i mean no one has the time to write a complet code from top to bottom .. i have give u the code and the idea on how it can be done .. ask questions as to what u cannot understand and I will try to explain further ...
muliganAuthor Commented:
Well you may be right, but I was able to find an example that I am using to use to get a good start.

lets take it step by step .. have u added the template columns as i suggested
muliganAuthor Commented:
Thanks for asking, but that link that I posted is helping a lot, and I think I will be able to work thru it.
I just had a look at that link .. its exactly the same approach that I suggested .. add itemtemplate and add the textboxes in them .. then loop through the grip to fetch each row to insert/update
muliganAuthor Commented:
Maybe, but this is something explained out in detail and something for me to download and start using and customizing.  Did you get a look at their demo they offer for download?  It isn't exactly what I'm looking for as I don't want to put all the values in textboxes as I don't want to allow editing on all the columns, but at least it is a good start.  I guess there is not a perfect solution out there for me to look at.  I will just have to muddle thru it.  I was hoping that 500 points would inspire someone to help me come up with a full solution, but I understand everyone is busy.
muliganAuthor Commented:
No one answered my question.  I found my full written sample at:


Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.