Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
I

Ironsmith1977

@Ironsmith1977
About
Posts
39
Topics
10
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • HTML Mailto tag???
    I Ironsmith1977

    Hey, Thanks for the info. It seems that this is not gonna happen without the use of scripts (asp, cgi, php). I'm restricted to only HTML and JavaScript, so I just set the contact buttons to open up Outlook. It would be nice to submit the form, but this server only supports HTML and JavaScript. Maybe one day if my client ever updates their service then I can submit forms. Thank you again. This site never lets me down. Ironsmith

    Web Development csharp javascript html sysadmin tools

  • HTML Mailto tag???
    I Ironsmith1977

    Hey, I need to know how to submit a form to an e-mail address. What I got right now just opens up Outlook Express. I don't want Outlook to open, I just want the info on the form to be sent to the E-mail address. This is the code I'm currently using. As for my books and anything I can find online, it's all basically the same as this.

    I'd love to be using a script or .NET for this, but the server that the site is uploading onto only supports HTML and JavaScript. It's not meant for much besides posting family photos. Cheers Ironsmith

    Web Development csharp javascript html sysadmin tools

  • Removing items from a datagrid???
    I Ironsmith1977

    OH MY GOD, it's working!!! lmfao! Thank you so much my friend, I will be singing your praises for weeks. lmfao. Take care Ironsmith

    ASP.NET css help tutorial question

  • Removing items from a datagrid???
    I Ironsmith1977

    The ItemID column is of Integer type, but when I take out the apostrophes I get a "Syntax error: Missing operand after '=' operator." error. On the line of code:

    DataRow[] rows = dt.Select("ItemID="+ id);

    Take care Ironsmith

    ASP.NET css help tutorial question

  • Removing items from a datagrid???
    I Ironsmith1977

    Well, I had that line of code in the wrong section...I had it in the click event, not the page load. But, it's progress, it got past that line and down to the next where it generated this exception error: "Cannot perform '=' operation on System.Int32 and System.String." This is the line of code:

    DataRow[] rows = dt.Select("ItemID='"+ id + "'");

    One thing is for certain, I'm learning more here from you than I have from my instructor all year! lol. Ironsmith

    ASP.NET css help tutorial question

  • Removing items from a datagrid???
    I Ironsmith1977

    This is where it stops:

    string id = PurchaseDataGrid.DataKeys[index] as string;

    I've tried altering [index], but that didn't work out so well. I've stepped through the code, and really I can't see why this code doesn't work. But this is the first time I'm using this sort of code, not to mention I just started ASP.NET(C#) a few weeks ago. Take care Ironsmith

    ASP.NET css help tutorial question

  • Removing items from a datagrid???
    I Ironsmith1977

    Oh that is awesome, I just did it and it works great. Good to know that I'm not completely screwed! Thank you very much! I'm back to the same problem, but I now have a unique identifier column. I just keep getting that "Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index" exception error. Any thoughts? Take care Ironsmith

    ASP.NET css help tutorial question

  • One DataTable two DataGrids???
    I Ironsmith1977

    Yes this one works now, strange thing too. It wasn't appearing on the form at run time, but the DataTable was there in session state. So I dropped the DataGrid and dragged a new one onto the form, and now it works fine. lol. Take care Ironsmith

    ASP.NET question

  • Removing items from a datagrid???
    I Ironsmith1977

    Is there a way to create a column that AutoIncrements? Or is there a way that I can hard code in row numbers? However, since I'll never know exactly how many rows there will be in the DataGrid, that's most likely not a good idea. Well, unless I can AutoIncrement a column somehow, I guess I'll just have to leave it as is, it deletes the first row. lol. Horrible, but I'm running out of time. Take care Ironsmith

    ASP.NET css help tutorial question

  • Removing items from a datagrid???
    I Ironsmith1977

    Hello, No its not. I think from what others have told me, it's because I don't have a unique identifier column. None of the columns in my table are unique, I don't have a "ItemID" column or any other numbering system in the DataGrid. Therefore, trying to specify what row to delete, has been the main problem. If you check out my first post in this thread, I posted my code. It hasn't changed much since I posted that. Take care Ironsmith

    ASP.NET css help tutorial question

  • Deleting a row from a datagrid with checkboxes???
    I Ironsmith1977

    Well that's just it I guess, none of the values that come into the DataGrid are unique for their row. For instance the seven columns are: Remove(checkbox), Brand, Color, Size, Material, Quantity, and Price. Sometimes all the columns are populated, sometimes they are not, it depends on the Item. With the exception of the Remove column, the other six columns could be several different values. I'll look into the DataKeyFields, though I do understand what you mean, I have no uniquely identifyable row. Take care, and you've been a great help! Ironsmith

    ASP.NET database html wpf wcf design

  • Deleting a row from a datagrid with checkboxes???
    I Ironsmith1977

    Ok, well it's an improvement, now its making it this far: string id = PurchaseDataGrid.DataKeys[index] as string; However, now I'm getting this error: "Must be non-negative and less than the size of the collection. Parameter name: index" I have no idea what this means, I'm thinking that because I don't have an "itemID" column, its conflicting with the strings in the table. But that's really just a guess. Also, should I be specifying a column name anywhere? Take care Ironsmith

    ASP.NET database html wpf wcf design

  • Deleting a row from a datagrid with checkboxes???
    I Ironsmith1977

    Ok, I didn't get it the first time, but thank you for clearing that up for me. Your right, that would be referencing the header, which only says "Remove", however, I didn't put a label on it or use any templates, I just added it in HTML view. So I tried to adjust the cell and controls indexes but that didn't work out so well. so I changed Controls[1] to Controls[0]. And now I get this error "Object reference not set to an instance of an object." And its highlighting the: if (chkRemove.Checked) { It's not getting any further than this. Take care Ironsmith

    ASP.NET database html wpf wcf design

  • Deleting a row from a datagrid with checkboxes???
    I Ironsmith1977

    Hello, I'm still getting the same error "Index out of range". Is it possibly because I specify the "int index = 0;" variable instead of a column heading? But I tried to specify a column heading and of course got a "cannot convert to string" error. See I can write: private void btnRemove_Click(object sender, System.EventArgs e) { DataTable dt = (DataTable)Session["Items"]; // PurchaseDataGrid.DataKeyField = "Remove"; int index = 0; foreach(DataGridItem item in PurchaseDataGrid.Items) { CheckBox chkRemove = item.Cells[0].Controls[1] as CheckBox; if (chkRemove.Checked == true) { // string id = PurchaseDataGrid.DataKeys[index] as string; // DataRow[] rows = dt.Select("Item='"+ id + "'"); // rows[0].Delete(); dt.Rows[0].Delete(); } } Session["Items"] = dt; PurchaseDataGrid.DataSource = dt; PurchaseDataGrid.DataBind(); } And this code removes the first row in the table. But this code at least checks to make sure that a checkbox is selected. Ironsmith

    ASP.NET database html wpf wcf design

  • Deleting a row from a datagrid with checkboxes???
    I Ironsmith1977

    Ok, I've been working on this for two days, even my instructor is lost on this one (not at all very encouraging). I'm making a shopping cart and based on which check box is selected, I need to delete that row out of the DataGrid. I'm not using SQL or any other database, though I do know its more efficient. I'm binding a DataTable to my DataGrid, and I know that I have to remove the row from the DataTable and then rebind it to the DataGrid. All of the columns and rows for the DataGrid are created in code, with the exception of the Check box column, that one I adding in HTML view. Here is a sample of how I'm creating my DataTable and then Binding it to the DataGrid, along with the Click event that should remove the row. private void imgbutSubmit_Click(object sender, System.Web.UI.ImageClickEventArgs e) { //CREATE A DATATABLE AND PUT IT INTO SESSION STATE. DataTable dt = null; if (Session["Items"] != null) { dt = (DataTable)Session["Items"]; } else { //CREATE THE COLUMNS FOR THE DATATABLE dt = new DataTable(); dt.Columns.Add("Brand"); dt.Columns.Add("Color"); dt.Columns.Add("Material"); dt.Columns.Add("Size"); dt.Columns.Add("Quantity"); dt.Columns.Add("Price"); } //CREATE THE ROWS FOR THE DATATABLE. DataRow dr = dt.NewRow(); dr["Brand"] = drpBrand.SelectedItem.Value; dr["Color"] = drpColor.SelectedItem.Value; dr["Material"] = drpMaterial.SelectedItem.Value; dr["Size"] = null; dr["Quantity"] = txtQuantity.Text; dr["Price"] = lblPrice.Text; dt.Rows.Add(dr); //ADD THE DATATABLE TO SESSION STATE. Session["Items"] = dt; } private void Page_Load(object sender, System.EventArgs e) { //CHECK IF THERE ARE ANY ITEMS IN THE CART. if (Session["Items"] == null) { lblEmpty.Text = "There are currently no items in your shopping cart."; } //BIND THE DATATABLE TO THE DATAGRID. if (!IsPostBack) { if (Session["Items"] != null) { DataTable dt = (DataTable)Session["Items"]; PurchaseDataGrid.DataSource = dt; PurchaseDataGrid.DataBind(); PurchaseDataGrid.DataKeyField = "Remove"; } } } private void btnRemove_Click(object sender, System.EventArgs e) { DataTable dt = (DataTable)Session["Items"]; PurchaseDataGrid.DataKeyField = "Remove"; int index = 0; foreach(DataGridItem item in PurchaseDataGrid.Items) { CheckBox chkRemove = item.Cells[0].Controls[1] as CheckBox; if (chkRemove.Checked

    ASP.NET database html wpf wcf design

  • Removing items from a datagrid???
    I Ironsmith1977

    I set the DataKeyFields in code actually, until run time, the DataGrid displays nothing with no column headers or anything. Only after Items are selected will the grid populate. The only static field in the grid is the "Remove" column, which is holding checkboxes. Take care Ironsmith

    ASP.NET css help tutorial question

  • One DataTable two DataGrids???
    I Ironsmith1977

    Hello, No I'm still in the same app. I got a shopping cart page, then a order details page, so all I do is hit a button to get to the next page. So anything in session state should still carry over to the next page right? Its like a cookie with user info, I can transfer that info to any other page in the app. So it should be the same with a DataTable in session state. Therefore, I used the same code to populate this new table as I did the other one. Take care Ironsmith

    ASP.NET question

  • Removing items from a datagrid???
    I Ironsmith1977

    I keep getting an exception error at the [index] saying its out of range, cannot accept negative values and must be below maximum value. I can't figure out what this means. I stepped through the code and the index value while stepping through is at 1. Any idea's? Take care, and you've been a huge help to me. Ironsmith

    ASP.NET css help tutorial question

  • One DataTable two DataGrids???
    I Ironsmith1977

    Hello, Yes I have the DataTable stored in session state, and no, performance isn't an issue on this one. I can bind the DataTable to one DataGrid no problem, but when I tried to bind it to the other one on a different form, it wouldn't work. I didn't recieve an error, there was just no DataGrid on the form. I did reuse the same code to bind this DataGrid as I did the first DataGrid though. Take care Ironsmith

    ASP.NET question

  • Removing items from a datagrid???
    I Ironsmith1977

    I'm not getting the compile error anymore, however, it will only delete the one row. I need to know how to delete the rows that are selected. The ASP.NET books that I have don't have anything on DataTables, as unbelievable as that sounds, and the info I'm finding online is very limited. I know that I'm specifying row[0] and that's most likely why I'm only deleting one row, the first row. So how would I change that to make it so I can delete anything that is selected? Ironsmith

    ASP.NET css help tutorial question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups