GridView with a custom button - asp.net

Specifically, I am using DevExpress 10.1 for their APSxGridView. I have a grid with a command column. I plan on using two of the standards: new and edit. I would like to create a custom button that will take a value from within the current row and redirect to another page using that value as part of the query string.
I have seen some suggestions to create a hyperlink column to do this, but I would like to have all of these commands in a single column. I can see solutions for this if I weren't constrained by leaving all buttons within a single column. Is this something that maybe I could assign during HtmlDataCellPrepared?
Thanks.

If it's anything like the standard .net GridView I would create a template field. In a template field you can put whatever you want in there. I have done this when I need an asp.net control (a button, hyperlink, etc) instead of the standard grid buttons and commands. You can then access controls and the datasource during the OnRowDataBound event handler and customize the button during run time if need be.

Related

How to create and edit gridview at runtime along with adding rows?

I have a aspx page consisting of a calendar button and a textbox.When we click calendar button then a calendar appears and the date which i select on calendar appears in textbox. Now what i want is to load the data from database according to the date selected and allow the user to edit it.And also i want to enable user to add rows at runtime. Do i need to create grid view at runtime?? Can somebody point me in a direction??
You don't need to create the gridview at runtime. You can define the gridview in the markup without having any data initially. You can set the calendar to autopostback and on the server side, capture the new date selected, grab the data based on that date and bind it to your gridview.
As far as editing the data, Gridviews already provide support for this and the amount of code that you need to write largely depends on how the datasource for the gridview is set up. If you use a SQLdatasource with the appropriate settings you practically don't have to write a single line of code besides the markup (Google: Gridview SQLdatasurce editing ASP.net).

ASP.net Using a Session Varriable to move a GridView SelectedDataKey to another page

Help please!
I am pulling out what little hair I have left over this and can't find an answer.
I am attempting to move the selected row in a grid view to another page and use the SelectedDataKey or the primary key value of the selected row to indicate what data should be displayed in a grid view on another page. This is the last little bit of a school project that I can't figure out.
What I am doing on the first page is to use a button click event to set a session variable that looks something like this. Session["Select"] = GridView1.SelectedDataKey; The button will then send the user to the next page. Response.Redirect("CustomerAccounts.aspx");
Once on the next page I want to use the primary key selected on the first page to show only the data with a coresponding value on the second page by using a where statement in the next gridview. So I am setting the [CustomerID]=? Session("Session["Select"])
Am I setting up the where correctly in the second gridview?
I like setting up such things with querystrings.
I made a video tutorial on youtube doing just that a while back
http://www.youtube.com/watch?v=HRjZ_0JpO2M&list=UUgtKyNvllU9E6c2Mi8OtzCQ&index=5&feature=plcp
I also made a tutorial showing how to load the detail gridview nested in the master gridview with jquery
http://www.youtube.com/watch?v=nJp14o_1wZQ&list=UUgtKyNvllU9E6c2Mi8OtzCQ&index=4&feature=plcp

Which control should I use to show post records from my database in ASP.NET?

Which control should I use to show post records from my database in ASP.NET?
On my project page I would like to show recently featured projects. The number of projects can vary. I'm looking for a control like GridView or something that alter the properties of accordingly to get data from my database.
Below is an image of what I would like my page to look like:
I have been told to use asp:ListView but I don't know how to use it. Is this the right solution for my problem?
You could use a GridView Class
Displays the values of a data source in a table where each column
represents a field and each row represents a record. The GridView
control enables you to select, sort, and edit these items.
Or a Repeater Class
A data-bound list control that allows custom layout by repeating a
specified template for each item displayed in the list.

State storage in GridView

gridview has 20 pages. The user is see first gridview page . He decide to apply highlite style using jquery on few row . Now he move to second page . He apply style this page too. Now when he go back to first page, he cannot see row with style he apply before he move to page 2.
How to store state of the rows style when user moving on pages? Perdon my English
Use a cookie to store highlighted rows on a given page. Hook up to a event on which highlighting takes place (click?) and add a code to rewrite a cookie with currently selected rows. When you will be printing the table just read the cookie and restore selections based on the value stored in it.
I would save the highlighted row id's in a hiddenfield. Pageing causes a Postback! Also you need some javascript code to re-highlight the fields.
If can afford to make the solution less efficient, I would change the highlight method so that in runs server side with a post back instead of using JavaScript and then put the GridView in a UpdatePanel.
Also remember to use DataSource object (e.g. ObjectDataSource) instead of binding your data manually using .DataBind() in the code behind. This should ensure that you don't rebind the data on every post back.

GridView Making a single Edit Item Template take the entire row

I've got this gridview. The gridview uses TemplateFields as the number of fields in the database's table. What I do next is use an ItemTemplate to present the correct column info.
Now, problems rise when the user click's Edit. Since I can only use EditItemTemplate to edit I am resulted with a control in each column. What I really want is to have a single row with no columns so I can easily style the edit mode (having a table with a different layout for example).
Is this possible? If so, how?
I suspect you will have to create your own specialized class that inherits from GridView and does its own rendering to accomplish this.
You might hack some workaround though... such as manually editing the rendered HTML output or DOM.

Resources