muligan
asked on
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,
M
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
ASKER
Let me check these out. Thanks
ASKER
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
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
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 ..
ASKER
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
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
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.Perce ntage(80.0 0);
//make grid look pretty
myGrid.CellPadding = 1;
myGrid.GridLines = GridLines.Both;
myGrid.ForeColor = Color.Black;
myGrid.BackColor = Color.Beige;
myGrid.AlternatingItemStyl e.BackColo r = Color.Gainsboro;
myGrid.HeaderStyle.BackCol or = Color.BlanchedAlmond;
//attach your event handler
myGrid.ItemCommand += new DataGridCommandEventHandle r(dataGrid _ItemComma nd);
myGrid.ItemDataBound += new DataGridItemEventHandler(m yGrid_Item DataBound) ;
myGrid.SelectedIndexChange d += new EventHandler(dataGrid_Sele ctedIndexC hanged);
myGrid.EditCommand += new System.Web.UI.WebControls. DataGridCo mmandEvent Handler(th is.EditRec ord);
myGrid.CancelCommand += new System.Web.UI.WebControls. DataGridCo mmandEvent Handler(th is.myGrid_ Cancel);
myGrid.UpdateCommand += new System.Web.UI.WebControls. DataGridCo mmandEvent Handler(th is.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. ButtonColu mnType.Pus hButton;
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.EditItemTempl ate = new EditDropDownListItem("Posi tionName") ;
myGrid.Columns.Add(tempPos ition);
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
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.
//make grid look pretty
myGrid.CellPadding = 1;
myGrid.GridLines = GridLines.Both;
myGrid.ForeColor = Color.Black;
myGrid.BackColor = Color.Beige;
myGrid.AlternatingItemStyl
myGrid.HeaderStyle.BackCol
//attach your event handler
myGrid.ItemCommand += new DataGridCommandEventHandle
myGrid.ItemDataBound += new DataGridItemEventHandler(m
myGrid.SelectedIndexChange
myGrid.EditCommand += new System.Web.UI.WebControls.
myGrid.CancelCommand += new System.Web.UI.WebControls.
myGrid.UpdateCommand += new System.Web.UI.WebControls.
//important to set it to false
myGrid.AutoGenerateColumns
//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.
editCol.CancelText = "Cancel";
editCol.UpdateText = "Update";
//id from database
BoundColumn colID = new BoundColumn();
colID.DataField = "ID";
colID.ItemStyle.Width = System.Web.UI.WebControls.
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.EditItemTempl
myGrid.Columns.Add(tempPos
myGrid.Columns.Add(editCol
myGrid.Columns.Add(colID);
//add myGrid to placeholder
PlaceHolder1.Controls.Add(
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
ASKER
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
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
ASKER
BTW.... I would like a vb.net solution
uhmm....never used dreamweaver...can't help you there....good luck though :)
ASKER
Basically dreamweaver is the same, but there is just no code behind.
ASKER
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 ...
ASKER
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
http://www.dotnetjohn.com/articles.aspx?articleid=83
lets take it step by step .. have u added the template columns as i suggested
ASKER
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
ASKER
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.
ASKER
No one answered my question. I found my full written sample at:
http://www.dotnetjohn.com/articles.aspx?articleid=83
http://www.dotnetjohn.com/articles.aspx?articleid=83
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.