[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

500 Points: Datagrid Help

Posted on 2005-04-12
22
Medium Priority
?
197 Views
Last Modified: 2010-04-07
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,

M
0
Comment
Question by:muligan
  • 11
  • 5
  • 2
  • +2
20 Comments
 
LVL 25

Expert Comment

by:nauman_ahmed
ID: 13762201
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.
0
 

Author Comment

by:muligan
ID: 13762319
Let me check these out.  Thanks
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:muligan
ID: 13762905
Guys,

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.

Thanks,

M
0
 
LVL 26

Expert Comment

by:Rejojohny
ID: 13762943
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 ..
0
 

Author Comment

by:muligan
ID: 13763138
Rejojohny,

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,

M
0
 
LVL 7

Expert Comment

by:brdrok
ID: 13763144
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");


myGrid.Columns.Add(tempPosition);
myGrid.Columns.Add(editCol);
myGrid.Columns.Add(colID);

//add myGrid to placeholder
PlaceHolder1.Controls.Add(myGrid);

myGrid.DataBind();


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
0
 

Author Comment

by:muligan
ID: 13763260
brdrok,

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.

Thx,

M
0
 

Author Comment

by:muligan
ID: 13763367
BTW.... I would like a vb.net solution
0
 
LVL 7

Expert Comment

by:brdrok
ID: 13763451
uhmm....never used dreamweaver...can't help you there....good luck though :)
0
 

Author Comment

by:muligan
ID: 13763642
Basically dreamweaver is the same, but there is just no code behind.
0
 

Author Comment

by:muligan
ID: 13765560
Still looking for help, if anyone is willing?
0
 
LVL 26

Expert Comment

by:Rejojohny
ID: 13771242
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 ...
0
 

Author Comment

by:muligan
ID: 13771604
Well you may be right, but I was able to find an example that I am using to use to get a good start.

http://www.dotnetjohn.com/articles.aspx?articleid=83
0
 
LVL 26

Expert Comment

by:Rejojohny
ID: 13771849
lets take it step by step .. have u added the template columns as i suggested
0
 

Author Comment

by:muligan
ID: 13772927
Thanks for asking, but that link that I posted is helping a lot, and I think I will be able to work thru it.
0
 
LVL 26

Expert Comment

by:Rejojohny
ID: 13773118
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
0
 

Author Comment

by:muligan
ID: 13773305
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.
0
 

Author Comment

by:muligan
ID: 13969674
No one answered my question.  I found my full written sample at:

http://www.dotnetjohn.com/articles.aspx?articleid=83

0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 14028278
PAQed with points refunded (500)

modulo
Community Support Moderator
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses
Course of the Month18 days, 3 hours left to enroll

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question