Editable GridView in ASP.NET - c#

I am looking for some help to get started on creating an editable GridView in ASP, I already have everything working in a Form Application. Now my plan is to convert it to a Web application using ASP.NET. Not too hard I'd say, but I just have some trouble with my GridViews. So here is what my current application does and what I want it to do in ASP:
I created multiple GridViews, with only a single column. Then on this column, rows will be added when the application is started, how many should be added is found in the database. Some of these rows will be filled with data from the database, some will be left empty. I already have the code for this, just need to convert it to work with ASP. I want the user to be able to edit all these rows, including the ones that are empty. These columns do nothing fancy, the user is only able to put numbers in them.
Since I'm completely new to ASP, I have no idea how to create a GridView that has empty editable rows with it. Maybe it's very simple, but a nod in the right direction would be very much appreciated! If anymore info is needed, please let me know
What i want to do in ASP.NET

GridView is one of the the most powerful control in the long line of controls since .NET released under WebForms, it is so vastly used that there are thousands of examples and tutorials to do almost everything.
Since my times learning the good things about the GridView, I always rely on 2 websites, and today I will make them my answer.
One, I can no longer found, was something like The GridView Guy, a lovely website with the best tutorials to raise the .NET control to do almost everything.
The Seconds is the famous Matt Berseth and all his tutorials surrounding not only the GridView but other controls as well.
http://mattberseth.com/blog/gridview/
There are plenty more tutorials out there for this, like:
http://www.codeproject.com/Articles/16769/Full-featured-Editable-GridView-Control
http://www.dotnetspark.com/kb/643-how-to-editupdatedelete-gridview.aspx
http://aspnet-with-c-sharp.blogspot.dk/2011/02/fully-editable-gridview-in-aspnet-2.html
You just have to follow up and if you find a wall that you can't climb, assure that someone around here can help you out, just show us what you need to do, and what have you tried.

Related

Has anyone had problems with identical controls working on a top level webpage, but not a lower-level webpage?

I apologize if this is not a proper question, but I am new to StackOverflow, so here goes...
I am programming in C# for the web in VS2005 (at the company I work for; I use VS2012 at home), and have written a somewhat lengthy program for work.
My problem is that I can add certain controls on the master/home page, such as a nested gridview or even a simple dropdownlist, and they work better than beautifully. When I add the exact same control, with the same SQL data source, to a lower-level webpage, they refuse to work. The SQL data loads just fine, but the SelectedIndexChanged or SelectedIndexChanging methods don't work. Yes, I have checked everything from AutoPostBack=true to the ViewState=true.
Oddly enough, almost every page (20+) in the program has at least one regular gridview, and they work like a charm on every page. I have not yet coded a regular gridview that has NOT worked.

c# creating grpah/chart by entering data. WinForm

So what I am trying to say, i have to create a WinForm, it should contain textboxes for entering data/points and a button that would create a graph. I have found a few usefull links, but can someone explain me how to do it because i stuck and dont know how to continue my working flow.
this one is for ASP, i tried the same with WinForms - does not work correctly http://www.c-sharpcorner.com/uploadfile/dbeniwal321/drawing-a-line-chart-in-gdi/
here is an example what i want to do - http://www.youtube.com/watch?v=D9lNbu-3oBE
My apologize for broken English!

Creating Repeater Template at runtime and based upon user input

Is it possible to dynamically create an ItemTemplate for a repeater somehow?
I am trying to use a repeater since it allows the most control, but one of my requirements is making me reconsider.
I basically have a number of SQL queries that I do through a web service. Rather than having users type in the entire query I want them to be able to select "parts", "products", or "packages" via radio buttons, enter a search term in a text box, and some other info, and the page returns the results they want. I have this mostly done, the RadioButtons control logic, and I have the query set up to accept the input from the text box as a search term with wildcards. The only probelm is I am struggling with the repeater control. The problem is each one of the tables has a different number of columns and they have different names, so doing a
<td><%# DataBinder.Eval(Container,\"DataItem.Description\") %></td>
within the ItemTemplate is not possible(I don't know until bind time which one of the 3(possibly more in the future)templates to use)
I tried using a literal to pass in what I wanted based on logic in the codebehind, but I couldn't pass the inline functions, and I have been unable to put together how to do this based on an earlier question.
I have been reading the MSDN reference and it seems like if I learn the DataList control it will make things easier, but I'd rather not waste time on that if there's an easy way to do it with a repeater(which will also allow me more control)
Thank you
I may be off track here but I think an easy solution to the problem you're having would be to create multiple repeater controls with different items templates inside them and wrap them up in panels. That way depending on the user parameters you could simply databind your result to the proper repeater and set the other panels to invisible.
I was looking back through some old code for you to see how I've handled similar situations. Then I saw Jesse's answer right before I wrote my reply. Basically, I would tend to agree with Jesse there - that seems the most straightforward solution from what you've outlined.
So I don't know how much this helps, but one possibility would be to use MVC Templates. MVC is handy in that it can actually be used in a very limited sense (your entire app doesn't need to implement it, just the applicable page) and it's also pretty straightforward.
An introduction on how to do different templates within MVC: http://bradwilson.typepad.com/blog/2009/10/aspnet-mvc-2-templates-part-1-introduction.html
It might be possible to modify the template so that it changes based on the object that it's bound to - like how a WPF DataTemplateSelector works.
I thought I remember seeing something in MVC3 or MVC4 that you could create a Template based on a datatype (like you can in Silverlight) and it would automatically pick that Template, but I'm having trouble finding that now.

ReBind Telerik RadGrid from RadToolBarButton +AJAX

I've been using Telerik Controls for a couple months now, and have yet to apply AJAX to any of my UserControls. While I've been learning, I've been doing full Postback's every time I need to Update a RadGrid or insert data. After getting my Web App looking the way I want it, I've realized that doing full Postback's not only looks bad, but it is quite slow.
At the moment all I am looking to do is ReBind a RadGrid using a refresh button on a RadToolBar. I am sure that once I grasp this, I will be able to apply AJAX to other places on my page.
I am currently running a Master Page, which consists of my Main Page, and my Main Page holds a RadTabStrip linked to a few other UserControls.
Does anyone know of any good (basic) tutorials that will aid me in learning AJAX with Telerik, as I am unfamiliar with both AJAX and Java, but am open to learning...
I recently run up into series of blog posts about AJAX and telerik ajax on their blogs - you can read them here. Also I know about a demo that does what you are asking for - toolbar incorporated into grid's command item, check it out.

Replacement for Index in .NET

I've been out of doing proper programming for sometime, so as an exercise in trying to get some practice, I'm trying to make a program to solve Sudoku in C# (VS 2010)
My problem occurs when I'm trying to create some form of initial grid for the data out of text boxes. Back when I used to use VB6, I could call all text boxes as a single name and then give them all an index number which would allow me to refer to a specific text box when I was in a loop.
As far as I can see, there's no easily visible equivalent in C# and my searching has been to no avail although I can't imagine it'd be a feature that would be removed.
Thanks in advance
You can create a control array.
http://www.devasp.net/net/articles/display/674.html
It would probably be easier, and look better, if you use a genuine grid control like the DataGridView.
One bit of bad news. In the days of VB4,5,6 Microsoft used to release a new grid control with every version of Visual Basic, which was annoying (unless you rewrote your code every year). Well, they are still at it.

Categories