I am doing a project in which i am getting data from a database and displaying in asp:gridview. i want to show a hyperlink column in which i want to show a proper named hyperlink for example "View" and when the user click on "View" the data from the DataTextField property is displayed in detail on another page let say "WebForm1.aspx".i have searched on net and have studied on msdn bt couldnt get. detailed help will appreciated .. piece of code as example will be helpful . thanks in advance.
Example:
data in the database table
NewsID NewsTitle NewsArticle (NewArticle field contains large amount of data)
i want to show a proper link named("view"). when user click on the view ,NewsArticle of the related record should be displayed in a new separate webpage.
One way to do this is for the hyperlink/url contained in each row of the grid view to contain the id of the record you want to view the detail, i.e.
View
then in the page_load event of the webform1.aspx you retrieve that record from the database and dispaly it on the page.
There are lots of ways to skin this cat, this is a relatively simple one. The code below is what you might use to generated the html above:
<asp:HyperLinkField HeaderText="Name" DataTextField="Id" DataNavigateUrlFields="DetailId" DataNavigateUrlFormatString="WebForm1.aspx?ID={0}">
</asp:HyperLinkField>
If you are familiar with Jquery you can user Dialogs
http://jqueryui.com/dialog/
Related
I am working on a website using C# in ASP.NET and have a page that contains a grid-view which displays the contents of one of the tables in my database. The fields are generic like Name, Description, Rating, ect. My question is how do you make it so that when one of the entries is clicked, it links to a new .aspx page that has all its information displayed in a nice format? An example of what I am talking about can be found at http://www.imdb.com/chart/top?ref_=nv_ch_250_4.
From my research I have found very little in the way of an answer, probably due to my inability to ask this question correctly. I assume your not suppose to physically create a new page for every new entry, because that could get crazy if you have lots of database entries coming in. Should there be one page created that auto-populates the required fields based on the specific values passed from the database entry selected, or when a user inserts a new entry into my database should I also create a new .aspx page? This question has had me stuck for quite some time, so I would appreciate any direction you can provide!
Create a simple hyperlink for all rows of the grid, the url of the hyperlink should contain a reference to that item like a ID or name. When the link is clicked you are passing the id to the second page in querystring. In the second page read the id(request.querystring) and display details accordingly.
>
Making the hyperlink : this is one way to do it. Add a itemtemplate column in the grid.
<Columns>
<asp:TemplateField >
<ItemTemplate>
View Details
</ItemTemplate>
</asp:TemplateField>
</Columns>
Brian,
You would have ONLY ONE new page that handles all of your entries in that table. You need to create this page such that it reads a query string from the URL, say with an id that corresponds to one of the records in your grid. In your grid, construct a link per record with an appropriate id that, when your newly created page receives it via URL, it can look up that one record in the database and populate the new page.
For example, a link in one of the rows of your grid could look like this:
/NewPage.aspx?id=123
Then, in the new page you created (NewPage.aspx) get the id that was passed and populate the page accordingly. For example:
string id = Request.QueryString["id"];
hi i have two xml file and i want to bind grid view eith this xml file on client side. i try to describe the complete senerio. in my .aspx page i have a drop down list which has number of department. when the user select the department the data i want the data according to department comes on the grid view from first xml file, in this gridview the rows are field with various tests and the row also have a checkboxes ,when user click on that checkbox the datafrom yhe second xml file will come and the second grid view is bind with that data. i want all that on client side. how is that possible, please help me and thanks in advance for help
I would suggest you to either use jqgrid/html table and use this article to read xml using javascript or if you wants to use gridview only and don't wants to show post back to the user then use updatepannel with gridview will help you out.
I am working with a Telerik Radgrid on an aspx page, which basically has to bind to a datatable, which gets populated by data returned from a web service. I need to be able to fill out some of the columns in the RADGRID based on the data returned by the web service.
For example, I need to be able to build the Hyperlink column based on the parts data returned by the web service. I need a way to access the datasource before the grid item gets populated and direct execution to a routine which builds the URL for the parts on a website.
Can anybody please suggest an efficient way to do this?
I highly appreciate any help/suggestions.
Thanks
Karthik
(Moving my comment to an answer, because I'm thinking this will work out for you.)
You could always cheat and bind it to the grid, allowing you to access the data, but then hide the columns so the users could never get the data.
Let me know how it works out.
EDIT:
My select statement is "select top 5 ProductName from products"
I then created a hyperlink column and assigned the properties under the data tab as such.
When run, it makes the data clickable and when clicked, it navigates to the url seen in the SS.
That what you need?
Ive got ASP.NET web application form where users enter details such as:
Subject Code
Subject Name
Subject Details ....etc
I would like the users to click on plus(+) or add button which creates new empty rows for users to fill above fields. They can enter up to x number of subjects.
Is there any easier way to achieve this?
Please note this is just one part of the form. The other part of form includes student details, comments etc. So ListView or GridView is not an option for me right now.
Thanks.
Regards,
I think ListView was a good choice here.
The ListView Control (Video).
ListView Web Server Control Overview.
However, refer to ASP.NET Data controls to get help in this issue.
I have a question. Let's say I had a number of controls which when I click "Add" the same group of controls would display again.
For example my grouped controls would look like this:
First Name: TEXTBOX
Last Name: TEXTBOX
ADD
When ADD is clicked an additional 2 textboxes appear. So on my page I'd have the following:
First Name: Someones Name
Last Name: Someones last name
First Name: TEXTBOX
Last Name: TEXTBOX
ADD
And so on....
Is there a control (multiview, etc) I could use to do this?
Many thanks in advance,
Jason
I would recommend using a UserControl. You can create them programmatically.
My favorite control in this scenario is the ListView, which allows you to define templates for regular items and the insert row.
Here is multi-part demo on the list view that will show you how it's done.
https://web.archive.org/web/20211020150712/https://www.4guysfromrolla.com/articles/010208-1.aspx
The control is especially effective if you are data binding to a data source, which can be a database or .NET objects. Although not directly applicable to the ListView, you may find this resource helpful, as it describes different uses for Data Sources:
http://msdn.microsoft.com/en-us/magazine/cc163862.aspx
The only way built-in is to use a listview control (or other repeating control) and set it up something like the following: http://mattberseth.com/blog/2008/05/bulk_inserting_data_with_the_l.html
Everytime add is clicked, you have to create a new object from the underlying data source that's blank and rebind the new data source in the listview or other control...
Otherwise, a custom/user control with programmatic creation would get the job done.