Hello I'm currently using GridView.Sort("Column", ASC") It works perfectly and sorts my gridview, however once I get to 10 or higher the sort order stops working and it goes. 1,10,2,3,4,5,6,7,9. Here is my code would anyone care to explain why it does this? [CODE] DataSet ds = new DataSet(); ds.ReadXml(Server.MapPath(@"xml\" + Request["Gradebook"] + ".xml")); foreach (DataColumn dc in ds.Tables[0].Columns) { dc.ColumnMapping = MappingType.Attribute; } //Dataview customised so that it can sort by, 'SortOrder' column. System.Data.DataView dv = new System.Data.DataView(ds.Tables[0]); dv.Sort = "SortOrder ASC"; gv.DataSource = dv; gv.DataBind();[/CODE] SortOrder is just a number from 1-100. Thank you!

Member Avatar
Member Avatar
+0 forum 2

Hello I'm currently trying to get my GridView to update all rows at the same time. The gridview takes data from an .XML file - I can use the 'onRowEditing' to update a single row at a time - however I want it to be able to update all rows at the same time. What is the best approach for this - I currently use a 'showEditButton' button but as said this only updates a single row. What would be the easiest way to update all rows - can I use a textbox in the gridview rather than a label …

Member Avatar
Member Avatar
+0 forum 1

Hello I'm trying to include a dropdownlist in my gridview and then bind data to that dropdownlist. I have come across an error: [quote] error CS0103: The name 'sortOrderDropDown2' does not exist in the current context at System.Web.Compilation.AssemblyBuilder.Compile() [/quote] Now i'm not sure why I get this error as my asp file clearly has a dropdown with the ID="sortOrderDropDown2" [code] <ItemTemplate> <asp:DropDownList ID="sortOrderDropDown2" AutoPostBack="true" runat="server" Visible="true"> </asp:DropDownList> </ItemTemplate> [/code] Now here is my PageLoad code in my c# file: [code] protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { //Get first/last sortOrder from XML file and display ArrayList sortOrderArrayMax …

Member Avatar
Member Avatar
+0 forum 1

Hello I'm trying to take Data from my GridView at the moment. My gridview has a column called 'DataField' what I want to do is take those values from Datafield to calculate the highest value. The 'Datafield' are as follows: A10, A11, A12 etc. How can I take those values (A10, A11, A12) and place them into a textbox, or calculate the highest value and put that into a textbox. My c# code for the DataBind is below: [code] void binddata() { DataSet ds = new DataSet(); ds.ReadXml(Server.MapPath(@"xml\" + Request["Gradebook"] + ".xml")); foreach (DataColumn dc in ds.Tables[0].Columns) { dc.ColumnMapping = …

Member Avatar
+0 forum 0

Hello I have an XML file that uses <Document Element> I was wondering if it is possible to sort my XML file by sortOrder? Here is an example of my code: [code] <?xml version="1.0" standalone="yes"?> <DocumentElement> <Item DataField="A03" Header="RDAW TEST" UseDefaults="Yes" SortOrder="1"/> <Item DataField="A01" Header="Eg: Assignment 1" UseDefaults="Yes" SortOrder="2" /> <Item DataField="A04" Header="RDAW TEST #2" UseDefaults="No" SortOrder="4" /> <Item DataField="A02" Header="Eg: Assignment 2" UseDefaults="No" SortOrder="3" /> </DocumentElement> [/code] I just want SortOrder to be sorted ascending when you view the XML file. Thanks

Member Avatar
Member Avatar
+0 forum 7

Hello I'm trying to sort my gridview by a particular colum. My gridview has a column which is 'Sort Order' and they are numbered 1,2,3 etc. Now I want to be able to default sort that column in ascending order. Would anyone possibly be able to help? Here is my ASP.net code: [code] <asp:GridView ID="rd" runat="Server" OnPageIndexChanging="pageddata" AllowPaging="True" AutoGenerateColumns="False" PageSize="30" CellPadding="4" ForeColor="#333333" GridLines="None" AllowSorting="true" OnSorting="onSort"> <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" /> <RowStyle BackColor="#EFF3FB" /> <Columns> <asp:TemplateField HeaderText="DataField"> <ItemTemplate> <asp:Label ID="lblDataField" runat="server" Text='<%#Eval("DataField") %>'></asp:Label> </ItemTemplate> <EditItemTemplate> <asp:TextBox ID="txtDataField" runat="server" ReadOnly="true" Visible="true" Text='<%#Eval("DataField") %>'></asp:TextBox> <%-- Visible=false to hide textbox, ReadOnly=true to make textbox …

Member Avatar
Member Avatar
+0 forum 5

Hello I currently have a Datagridview which takes data from an XML file. I want to display the array of numbers. Here is the code for my GridView: <asp:GridView ID="rd" runat="Server" OnRowEditing="Editdata" OnPageIndexChanging="pageddata" OnRowDeleting="Deletedata" OnRowUpdating="Updatedata" OnRowCancelingEdit="Canceldata" AllowPaging="True" AutoGenerateColumns="False" PageSize="30" CellPadding="4" ForeColor="#333333" GridLines="None"> <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" /> <RowStyle BackColor="#EFF3FB" /> <Columns> <asp:TemplateField HeaderText="DataField"> <ItemTemplate> <asp:Label ID="lblDataField" runat="server" Text='<%#Eval("DataField") %>'></asp:Label> </ItemTemplate> <EditItemTemplate> <asp:TextBox ID="txtDataField" runat="server" ReadOnly="true" Visible="true" Text='<%#Eval("DataField") %>'></asp:TextBox> <%-- Visible=false to hide textbox, ReadOnly=true to make textbox ReadOnly --%> </EditItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Header"> <ItemTemplate> <asp:Label ID="lblHeader" runat="server" Text='<%#Eval("Header") %>'></asp:Label> </ItemTemplate> <EditItemTemplate> <asp:TextBox ID="txtHeader" runat="server" Text='<%#Eval("Header") %>'></asp:TextBox> </EditItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="UseDefaults"> …

Member Avatar
Member Avatar
+0 forum 5

Hi, I'm trying to create a Web Form in C# - the form has a username and password textbox. The user enters there username and password which I want the program to check if it exists in the SQL database. I'm trying to create a login.cs class and then run the code on my form to check if the user information is correct however i'm struggling. My login.cs class: [code] using System; using System.Collections.Generic; using System.Text; using System.Data; using System.Data.SqlClient; namespace assignmentForm { public class UserLogin { private SqlConnection connection = new SqlConnection(); public UserLogin() { ///create sql connection connection.ConnectionString …

Member Avatar
Member Avatar
+0 forum 7

Hey, My database currently stores the location of a specific image, however i'm trying to get the page to change the [CODE]img.ImageUrl = "C:\mug.jpg";[/code] However it doesn't display the image, is there any reason for this? If I use a local image it works perfectly IE: [CODE]img.ImageUrl="~/images2/mug.jpg";[/CODE] Any ideas at all please?

Member Avatar
Member Avatar
+0 forum 3

Hi, I've currently got a gridView which selects data from my table, it also has the URL of an image in one of the columns. I want an imageField which can then display the image from the URL thats provided in the image column. My datagrid: [img]http://i41.tinypic.com/25ivst2.jpg[/img] My code for the DataGrid: [code] <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" Height="234px" Width="459px" AllowPaging="True" AllowSorting="True" onselectedindexchanged="GridView1_SelectedIndexChanged"> <Columns> <asp:BoundField DataField="imageSrc" HeaderText="imageSrc" SortExpression="imageSrc" /> <asp:BoundField DataField="CoffeeName" HeaderText="Coffee" SortExpression="CoffeeName" /> <asp:BoundField DataField="CoffeeStrength" HeaderText="Strength" SortExpression="CoffeeStrength" /> <asp:BoundField DataField="CoffeeGrind" HeaderText="Grind" SortExpression="CoffeeGrind" /> <asp:BoundField DataField="StockLevel" HeaderText="Stock" SortExpression="StockLevel" /> <asp:TemplateField HeaderText="Icon"> <ItemTemplate> <asp:Image ID="Image2" runat="server" ImageUrl='<%# Eval("imageSrc") %>' AlternateText='<%# Eval("imageSrc") …

Member Avatar
Member Avatar
+0 forum 2

Hey, I currently have a dataGridView which displays information from my SQL database. I have a button that I use to update/add into the SQL database - for example a user ammends a field in the dataGridView this automatically updates the database. I now want to implement a button that deletes the selected row from the database. My dataGridView loadData: [code] private void LoadData() { string connectionString = @"Data Source=localhost\sqlexpress;Initial Catalog=coffee;Integrated Security=True;Pooling=False"; conn = new SqlConnection(connectionString); sql = "SELECT * FROM coffeeType2"; da = new SqlDataAdapter(sql, conn); conn.Open(); ds = new DataSet(); SqlCommandBuilder commandBuilder = new SqlCommandBuilder(da); da.Fill(ds, "coffeeType2"); bsource.DataSource …

Member Avatar
Member Avatar
+0 forum 9

Hi i've got a simple username and password entry on my webpage. My login class works perfectly in Windows Form but not in my Web Application Login class: [code] using System; using System.Collections.Generic; using System.Text; using System.Data; using System.Data.SqlClient; namespace assignmentForm { public class UserLogin { private SqlConnection connection = new SqlConnection(); public UserLogin() { ///create sql connection connection.ConnectionString = @"Data Source=localhost\sqlexpress;Initial Catalog=coffee;Integrated Security=True;Pooling=False"; connection.Open(); } public Boolean Login(String username, String password) { SqlCommand cmd = new SqlCommand("SELECT * FROM [users] WHERE [username]='" + username + "' AND [password]='" + password + "'", connection); SqlDataReader reader = cmd.ExecuteReader(); bool found …

Member Avatar
Member Avatar
+0 forum 6

Hi, I currently have a dataGridView which is populated with data. However, I now need to be able to add or edit the data in that dataGridView and the changes then update my SQL database. My code for the dataGridView [code] private void main_Load(object sender, EventArgs e) { //create the connection string string connString = @"Data Source=localhost\sqlexpress;Initial Catalog=coffee;Integrated Security=True;Pooling=False"; //create the database query string query = "SELECT * FROM coffeeType"; //create an OleDbDataAdapter to execute the query SqlDataAdapter dAdapter = new SqlDataAdapter(query, connString); //create a command builder (SQL) SqlCommandBuilder cBuilder = new SqlCommandBuilder(dAdapter); //create a DataTable to hold the query …

Member Avatar
Member Avatar
+0 forum 1

Hi, I'm trying to get my program to write the content of textbox1 into a textfile specified at a particular location. However I get an error when trying to do so. My code: [code] protected void btnSave_Click(object sender, EventArgs e) { //Write to fileupload location System.IO.StreamWriter StreamWriter1 = new System.IO.StreamWriter(FileUpload1.PostedFile.FileName); //Writing text to the file. StreamWriter1.Write(TextBox1.Text); //Close the file. StreamWriter1.Close(); } [/code] Now i've checked the FileUpload1.Postfiled.Filename and it shows as text.txt - rather than the location clearly entered into FileUpload1 which is "C:\\Users\\Name\\Desktop\\test.txt". If i specify the location it works perfectly, however I want user to first select the …

Member Avatar
Member Avatar
+0 forum 1

Hi, I'm trying to use the asp.net Input (file) with my program - i've placed it ont my program and I can click browse and it locates the file I want. Eg: "C:\Users\Name\Desktop\test.rtf" However, I then want to have it so that when I click a 'Submit' button it reads the contents of test.rtf. How can I implement this into a button? Thank you.

Member Avatar
Member Avatar
+0 forum 8

I need to create a program that can read a file a user has selected, i'm trying to use this with the HtmlInputFile in Visual Studio. The file then needs to be read and encoded, i've created a class that deals with the encoding and adds +13 onto each letter to encode it. Encode.cs [CODE]using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Text; namespace Coursework_Exercise2Web { public class encode { private string encodedMessage; private char[] originalMessage = new char[100]; public string encodeMess(string m) { originalMessage = m.ToCharArray(); for (int i = 0; i < originalMessage.Length; i++) { originalMessage[i] = …

Member Avatar
Member Avatar
+0 forum 1

I'm trying to create a login system that checks the username and passsword from an sql database. I've created a local server named coffee that has a table named 'users' - I have created fields for username & password. I'm using ASP.NET web application and I want to connect to my SQL database 'coffee' and check that if username / password typed into textboxes is the same as database then redirect to new page. I've tried looking at a few tutorials but its confusing the hell out of me. I've tried creating my connection string to the database. [CODE] protected …

Member Avatar
Member Avatar
+0 forum 6

The End.