Forms Data Controls :: Manually Filling A Gridview?

Sep 7, 2010

I don't want to databind a gridview, I want to be able to add rows myself within c# code. I can see there is a GridViewRow object and wondered if I can use this to add/remove rows as required?

View 5 Replies

Similar Messages:

Forms Data Controls :: Filling A GridView And Its PageIndexChanging

Feb 14, 2010

In a webform I have two textbox (txtDNI and txtAPE), 2 buttons (b1 and b2), 1 gridview (myGV) and 2 functions (dt1 and dt2) that return a DataTable txtDNI will be a parameter for dt1 function and txtAPE will be a parameter for dt2 function

DNI [_______] (b1)
APE [_______] (b2)
[ | | | | ]
[ | | | | ]
[ | | | | ]
[ | | | | ]
[ 1 2 3 4... ]

When I press b1 myGV will be fill with the dt1 function's datatable and when I press b2 myGV will be fill with the dt2 function's datatable myGV allows paging=true and when I press the next index (2 or other) It appears a PageIndexChanging error. So the pagination isn't automatic and I have to code the PageIndexChanging event When I use a ObjectDataSource and I connect it with myGV the PageIndexChanging error dessapears and the pagination is automatic The problem is the ODS only have a one selectfunction (dt1 or dt2) but not both and the configuration is on design time

The same happen with the PageIndexChanging event where I fill myGV again (with dt1 or dt2) and set the new index (myGV.PageIndex = e.NewPageIndex) and What is the problem?? ... the problem is, for example, when the user erase txtDNI and change index of pagination ... the PageIndexChanging event is fired and call the dt1 function but the txtDNI(parameter) is empty and occurs an error, the function returns an empty datatable and myGV is empty too for avoid this I create viewstates variables for each function, so I have a 2 viewstates and fill them when the user press b1 or b2 When user press the pagination, the PageIndexChanging event catch the viewstate variable and convert it into a datatable and the problem of the automatic pagination is controled The problem is I don't have 1GV in the webForm I have 5GV in some pages... and I try to avoid...

1. all the code in the PageIndexChanging events of each GV in the webform.
2. use the viewstate variables

View 3 Replies

Forms Data Controls :: Dynamically Filling A GridView With HyperLinks?

Jan 20, 2011

I need a GridView with 6 columns, one of which ("ItemID") is a HyperLink who's URL and text is determined from the C# code as I will get that data from an SQL database

INITIALLY, what I wanted to do, which would have been easy as pie, is:


HOWEVER, this does not work because every row in the Item ID column is filled with "System.Web.UI.WebControls.HyperLink". Apparently, this is what the HyperLink's toString() method returns. Apparently, you can't just throw a HyperLink into a DataRow and call it a day. I need to know how to make this ItemID column into such a HyperLink. It doesn't necessarily HAVE to be a HyperLink control, it just has to be able to call my javascript function on the aspx page, "popUp(URL)"

To give you a visualization of what I'm trying to achieve: this is a change log for an inventory system. The ItemID column indicates what item was altered. However, simply just having a number there doesn't say much, so I'm trying to create a link with the text, for example, "42 (motherboard x)". In other words reader["ItemID"] + " (" + reader["Description"] + ")", and that link will run a javascript function I have called popUp(URL) which takes a URL and opens it in a new window of specific size and location, to view that item's details.

I've tried various other methods such as disabling AutoGenerateColumns and manually create a HyperLinkField, but to no avail, because I couldn't get it to run my javascript function that way.

View 6 Replies

Forms Data Controls :: Gridview Sort Manually With Button Outside Of Gridview?

Jan 18, 2011

I have a gridview with data. I want a button which is not part of the gridview. Then if I press a button the gridview is sorted by two colums. i.e column1 ascending column2 descending.

I am not looking to work with a Sqldatasource as I use a data access layer. So the sort would have to be from a datatable and databind or directly with the gridview.

View 3 Replies

Forms Data Controls :: Inserting A Row In Gridview Manually?

Jan 5, 2010

I want to insert an extra row in the gridview in the RowDataBound event (or another place if thats possible). How can I do that?

The data in the row to be inserted is not part of the resultset, but rather to split the gridview in logical sections.

View 19 Replies

Forms Data Controls :: Way To Update For A Manually Bound GridView

Mar 3, 2010

I am having a hard time updating from my gridview based the value that I am setting in the datakeynames it is the Ucc field I keep getting and index out of range exception on the e.keys[0]. I have done this before so I am confused what I am missing here.

View 8 Replies

Forms Data Controls :: How To Change Row Color Manually In Gridview

Nov 8, 2010

I m having a gridview and Next and Previous button below gridview. If I click on next, I want to highlight the next row.

If i click on Previous, I want to highlight the previous row.

View 2 Replies

Forms Data Controls :: How To Manually Call A Gridview Event

Jan 6, 2010

Example. I need to manually call the test_RowDataBound event.


I tried this as I've used with buttons in the past.

button1_click(this, EventArgs())

but it dosen't work

View 2 Replies

Forms Data Controls :: Manually Binding GridView With SQL Statement.?

Feb 9, 2010

I have a gridview that I am manually binding in my code behind page because I have to pull out information from other sources for the WHERE clause.The issue is that I get an error on the aspx page that one of the columns is not in the dataview, however when I run the SQL statement in SQL all the columns are there and there is not a spelling error.If I remove the column from the gridview then the page loads.I cannot see why the column is a problem.Here is my ASPX gridview code.


This is the line where the error occurs. <asp:Label ID="Label2" runat="server" Text='<%# Bind("date_submitted") %>'></asp:Label> Here is the code behind


Here is the ending SQL statement that works in SQL and does return the date_submitted column. SELECT id, title, date_submitted, (SELECT username FROM users WHERE (id = t.submitted_by_user_id)) AS submitted_by, (SELECT name FROM departments WHERE (id = t.department_id)) AS department FROM tickets AS t WHERE (closed_by_user_id IS NULL) AND (department_id = 48 OR t.department_id = 83) ORDER BY t.date_submitted DESC

View 2 Replies

Forms Data Controls :: Manually Add Items To Gridview With Sqldatasource?

Mar 22, 2011

Can you add a row of data programatically and bind it to the gridview? If so, how?

I have a grid with 2 columns. One of these columns is a template that runs a function and delivers an output. Within that function I need to manually add data that is not present in the sqldatasource to the grid and use it when performing aggregate functions.

ColumnA - ColumnB
1 - MyFunction(1) - adds new row (1, B)and returns A to column B.
2 - MyFunction(2) - May return just A

Grid should look like
1 - A
1 - B
2 - A

Even though SQLDataSource only returns
1 - AB
2 - A

View 1 Replies

Forms Data Controls :: Manually Fire A GridView ItemCommand Event?

Mar 19, 2010

I've got a GridView control with LinkButtons in different cells. Currently when someone clicks a link, it fires the ItemCommand passing the CommandName and the ID of the item the link is bound to. That all works fine. I need to modify it now to not use links anymore. It now needs to show a popup balloon with a link (styled to look like a button) and when the link is clicked, I want it to do the exact same thing. I'm sure there are several ways of doing this, but for time's and consistency's sake, I'm copying the method used from another page we have that is already doing this. It has a hidden DIV on the page with the link in it. When you hover over a link, javascript repositions the div and makes it visible.

So what I need to do is pass my CommandName and item ID to the javascript so that it can trigger the postback when they click that single link. I know this is not the only way to get to the end result, but what I want to do if possible, is still fire the GridView's ItemCommand and set he DataListCommandEventArgs' CommandName and CommandArgument properties. Can someone explain how, under normal circumstances, clicking the LinkButton in the GridView fires the ItemCommand? I know that the LinkButton's click event is forwarded to the GridView but what gets sent from the client side that let's the server know the link was clicked?

View 5 Replies

Forms Data Controls :: Edit Or Update Data In Gridview Manually Without Auto Generate In C#?

Mar 12, 2010

how to edit data in grid view manually without auto generate in gridview + ajax.

View 4 Replies

Forms Data Controls :: Way To Manually Setting Up Gridview Fields And Sorting Using Datatable

Mar 20, 2011

I have a need to call Oracle stored procs to populate a gridview. I'm able to call one stored proc to get the column header text and another one to get the corresponding data. Currently I'm using a datareader, but I want my gridview to have sorting and paging enabled, so likely I'll need to read the data into a datatable and then bind the gridview to it.I've never had to manually configure a gridview - usually just use autoformatting.1. Do I essentially set up the columns manually in the gridview since it has no data to go off of in design mode? I'm guessing most of these will be Bound fields. A few of my columns are going to display date values that need to be formatted a certain way
and one column will be a link that needs to call a second method to populate a different grid. I'm not sure what the syntax for this is.

View 2 Replies

Forms Data Controls :: Manually Setting The Column Width On GridView Columns?

Mar 30, 2010

I have a GridView with bound columns, for which I am manually setting the ItemWidth and HeaderWidth to 500px, and nothing happens. Is there some trick to getting this to work?

This is a column a large amount of text in it, and it keeps sizing to the width of the header text, which is simply "note". I don't want to set Wrap to false, becuase then the colummn could be thousands of px wide in cases.

View 11 Replies

Forms Data Controls :: Way To Add Manually Data To Gridview

Jan 8, 2010

I have tried a few different ways to add columns of data to a gridview. I have just about got success, except for I am having problems with only getting the last value in my array of data to insert into the gridview column. For example if I return 4 rows from an sql query, with the values of 2, 4, 6, 8. The last value (8) shows in all for rows of the gridview for that particular column.

View 8 Replies

Forms Data Controls :: Manually Handling Sorting In Gridview Populated By File System?

Jun 21, 2010

not quite sure where I'm going wrong here. I'm trying to manually handle sorting in a Gridview that is populated with the following data source:




At the moment, nothing is happening when I click on the column headings. I ran it in debugging mode in Visual Studio and put a breakpoint on the Sorting event handler. I noticed that the variable dtSortTable is empty even after the TryCast(VacanciesGV.DataSource, DataTable). If I hover over this statement in debugging, it shows the data from the file system, so it does appear to be reading it.

View 4 Replies

Forms Data Controls :: SQL Timestamp In GridView And Manually Added Update Parameter For Stored Procedure In C#

Nov 4, 2010

I have a SQL table containing a timestamp column. This table is displayed in ASP using GridView control. The timestamp column is indicated in the DataKeyNames property of the GridView. I'm using TemplateFields for all columns and a ItemTemplate HiddenField control connected to the timestamp column using Eval.

Eval("timestamp") %>'

The data is displayed properly. I'm trying implement the optimistic concurrency in C# using the value of above mentioned timestamp and a stored procedure. The SQL stored procedure expects the @timestamp as varbinary(8). I'm not sure how to pass the value of gv_hid_timestamp back to the stored procedure. I'm using the following:

command.Parameters.Add("@timestamp", SqlDbType.Binary).Value = Byte.Parse(((HiddenField)gv.Rows[row].FindControl("gv_hid_timestamp")).Value);

resulting in the following error: "Input string was not in correct format." (I also tried different data types but with similar result). I want to be able to pass this parameter programmatically from C# and not have to specify it on the UpdateParameters list.

View 2 Replies

Forms Data Controls :: Saving Radiobutton "state" On Manually Data Sourced GridView?

Aug 3, 2010

I want to use a radio button selection on a GridView. I can get this working with a regular DS. However, my table is manually DS'd. When the page frame holding the GridView is loaded, I trigger that event to fire off the subroutine that loads a DataTable and adds the DataTable to the DataSource of the Gridview.

The Gridview has a radio button in the first column as the "SELECTED ROW" appearance. Whenever I run the onchange event code for the radio button, I try and fix the radio buttons so only one row is selected with the following code:


This code works fine with the gridview if its got a built in SQLLDataSource. However, with my manual assigning of DataSourcing to the Gridview on Frame Load, I believe the gridview is being reinitialized everytime and I'm loosing the state of the radio button. I don't believe I can use the IsPostBack() because sometimes this frame and gridview will be showing sometimes it won't and yet other times it will need to be "recreated" with new data dynamically within the page. However, I tried to use PostBack and it looks like its working until I try and do a sort...than that crashes.


When I click on Sort, it crashes here

If (mydata.Rows.Count <> 0) Then

(its complaining about it being "null")


View 9 Replies

Forms Data Controls :: Filling A Repeater With VB?

Feb 4, 2010

I have a set of images which needs to be displayed horizontally on the page. When the set of images reaches the edge of the browser window, they need to continue being displayed horizontally even if it means a horizontal scroll bar is made (In fact it will almost always result in a horizontal scroll bar forming).

I have tried to find some way to get images to push of the side of the page but can find no way (using basic CSS) without defining a width on a container holding the images (eg. 8000px). This is not possible as the width is dynamic (more or less images may be displayed as they are added to the database)

So my solution in theory:

I now record the dimensions of the image in the database when it is uploaded to the server. Using a repeater, if I add together the width of each image as they are loaded then I can use this number to define the width of the container. Seems to make sense right?

The problem comes when I load the images. I am not great at using the Repeater at the best of times and once again it has got me stuck. I have used the Repeater ItemCreated in my code behind but my variable which I declare (dim i as integer = 1) appears to get reset each time.

When I tried in Repeater OnLoad it didn't seem to work either.

The scenario in question can be found here: [URL]

You can see I have responsed the variable in the top left and they are all 1, hence why I believe the variable is being reset.

View 3 Replies

DataSource Controls :: Filling A Gridview With A Multiple SQL?

Aug 3, 2010

i have a table containing multiple agents , another three containing events ( three types of events , each category in a diffrernt table) organised by each agents! , i have to figure out how to fill a grid view that regroups a summary of the activity of every agent ! for example :

agent1 3 0 2 agent2 4 4 1
agent3 5 4 2

that means that the agent 1 have organised 3 EVENT1 0 EVENT2 and 2 EVENT3 ....

i have used the count(*) clause to fgure out the number of rows in table events referencing to each agent (group by) but it seems that value 0 is not returned by the clause , so i'm having a problem getting the exact values!

secondal , i have putted two calendar that will fix the beginnig and the end of the summary , but it seems that the end day is not included : it says 18/01/2010 00:00:00 and i have some events planned in 18/10/2010 14:10:00 so they are not counted !

View 4 Replies

Forms Data Controls :: DetailsView Filling DropDownList?

Mar 13, 2010

I've got a DropDownList in my <EditTemplate> and i'd like to fill it by data from database

(I can't use SqlDatasSource).

How to do that?

i was trying something like that

((DropDownList)((DetailsView)sender).FindControl("autor")).DataSource = MethodIveCreate();

on DetailsViewChanging method nut i've got error :/

View 3 Replies

Forms Data Controls :: Filling Table Like Photo Album?

Mar 1, 2011

I need to create a display grid of picture cells 5 columns by rows determined by database select. Each cell to contain picture, title, name, phone number pulled from database. How do I create a table like structure and populate it? Can a DetailsView control be called into each table cell with the table row count being determined by the same select statement?

View 2 Replies

Forms Data Controls :: Filling Web User Control From Web Form Page

Mar 4, 2011

I have a Web User Control that is sitting in a Tabcontainer on a web page. The user control is on tab 1 and has a listview control in it. In the listview control I have a textbox called txtWorkOrderID. In tab 2 I have a gridview with a button in one of the columns. When the button is clicked I want to grab the ID from the row I'm on and fill the txtWorkOrderID with it on tab 1. I've got things to work as far as grabing the ID and switching back to tab 1, but I keep getting a null reference when I try to put the value into the txtWorkOrderID which tells me its not finding the control. I am using .netVB in VS10. how to reference the textbox in the control on tab 1. here is what I have so far. [Code]....

View 4 Replies

Forms Data Controls :: Filling FormView's Child Controls?

Oct 15, 2010

I need to programmatically fill DropDownList in FormView and can't find the proper event to do it. I keep getting "'GenreList' has a SelectedValue which is invalid because it does not exist in the list of items" or "Bind, Eval can only be used in databound control" depending on the event. Sample code follows (there's no attempts to bind a DropDownList there ):


View 7 Replies

Forms Data Controls :: How To Manually Populate Listview

Oct 11, 2010

How can I manually populate a listview control without sql connection?

View 3 Replies

Copyrights 2005-15, All rights reserved