There are no errors, the gridview has the correct data, except the gridview is not is the placeholder, it is where I have positioned the gridview on the form. If I create the gridview in the aspx.cs page, then it works. Thanks
scjsb
Posts
-
How to add gridview to placeholder -
How to add gridview to placeholderI have created a simple gridview in my aspx file and tried to add this gridview to a placeholder in the aspx.cs file, but it does not work. To control the placeholder I am using a sytle sheet. If I create the gridview in the aspx.cs file, then add it to the placeholder it does work. Code snippets are below. All I want to do, is add gridviews to placeholders, which seems simple enough. Any help is appreciated. Created gridview in aspx file as:
-
How to display a jpg on a web pageI have a simple question. I am trying to display a jpg on my web page. I have a help.aspx page with this line of code but it does not display. I created a directory under App_Data named JPG and the jpg image is in there. When I use the intelisense, VS can locate the jpg, but when I run the page, the image is not displayed. I have tried using just a plain html page and it does not work either. I am missing something, but what? Thanks
-
How to create an array of buttons then access attributes in event handlerI am trying to learn C# etc by making this code work, its a mix of examples I've found on the web. The problem is the event handler never triggers. I would also like to change the text of the button that was clicked in the event handler. In a nutshell, I want to create an array of buttons, then change attributes as the text or color of the button selected. Eventually I want to add an array of labels which correstpond to these buttons and change the text or color depending on which button is pushed. Any help is appreciated. public partial class _Default : System.Web.UI.Page { static Button[] btn_arr = new Button[14]; static int btn_count; protected void Page_Load(object sender, EventArgs e) { try { if (btn_arr[0] is Button) { foreach (Button button in btn_arr) { add_button(button); } } else { for (int i = 0; i < 14; i++) { Button new_button = new Button(); new_button.ID = "btn" + Convert.ToString(i); new_button.Text = "Button" + Convert.ToString(i); new_button.Click += new EventHandler(btn_Click); btn_arr[btn_count++] = new_button; add_button(new_button); } } } catch (Exception ex) { lblStatus.Text += ex.Message.ToString(); } } protected void add_button(Button button) { try { panelLineA.Controls.Add(button); } catch (Exception ex) { lblStatus.Text += ex.Message.ToString(); } } // this is never triggered void btn_Click(object sender, EventArgs e) { int btnIndex = Convert.ToInt32(((Button)sender).ID.Substring(3, 1)); lblStatus.Text = "Button " + btnIndex + " was pushed." + ((Button)sender).ID; } }
-
How to declare an use a struct containing an array?Thanks for all your inputs, I've got it working as a class. I still don't know how to make this an array using this structure. What I need is an array of 200 records with each record having the structure as originally shown and guidance on how to actually use it.
-
How to declare an use a struct containing an array?I want to declare a simple array of stuct with the struct containing an array as shown below. But it does not compile. If you can't tell I'm very new to C#. public struct ChangeRec { public datetime LastTimeStamp; public int last ; public int mode[10] ; // I want an integer array of values } if I change the last line as shown, it will compile, but how do I control the size and access the elements? public int [] mode ; This seems too simple to be this hard. Thanks
-
Detect NULL values before trying to AVG dataI am trying to calculate the AVG for fields in a SQL SERVER database for a specified time interval. There may be times when there is no data for this interval. What would be the SELECT statement which will not execute the AVG of data if there is no data. I have tried to use "WHERE field IS NOT NULL", but this still throws an exception and stops execution of the program.