Error On Binding The Grid With A List?
Jan 20, 2011List<business.clspluginsprp> objprp = new List<business.clspluginsprp>();
business.clsplugins obj = new business.clsplugins();
for (Int32 i = 0; i < k.Length; i++)
[code]...
List<business.clspluginsprp> objprp = new List<business.clspluginsprp>();
business.clsplugins obj = new business.clsplugins();
for (Int32 i = 0; i < k.Length; i++)
[code]...
We are in the process of migrating our current asp.net gridviews to silverlight grids. The challenge that I am facing here is that in the gridview, the grid is bind to a dataset/datatable. But in silverlight, I do not have dataset/datatable available in the silverlight class. So only option is to create a Webservice and convert the dataset that I am currently getting from business layer to a class that imlements IList<> (unless there are any other ways). Now to convert this dataset to Ilist, I have to loop through the dataset to load the List. In my current dataset I have almost 10,000 records or even more in some cases. So the response time will be really slow.Are there anyways to
1) Load the List from dataset directly without looping through ?
2) Fetch the data from database directly to a List without having loading the dataset ?
List<ThemeObject> themeList = (from theme in database.Themes
join image in database.DBImages on theme.imageID equals image.imageID
into resultSet
from item in resultSet
select new ThemeObject { Name = theme.Name, ImageID = item.imageID}).ToList();
dgvGridView.DataSource = themeList;
dgvGridView.DataBind();
The list object populates fine. The datagrid is setup with 2 columns. A textbox column for the "Name" which is bound to "Name" An image column which is bound to the "ImageID" field. When I execute the code I receive the following error on the DataBind() Could not determine a MetaTable. A MetaTable could not be determined for the data source '' and one could not be inferred from the request URL. Make sure that the table is mapped to the dats source, or that the data source is configured with a valid context type and table name, or that the request is part of a registered DynamicDataRoute. I'm not using any dynamicdataroutes as far as I can tell. Has anyone experienced this error before?
I have a class with all different kinds of data members, including a list of strings. When I bind the data to a GridView, I want to be able to separate out the list of strings into different columns in the GridView. These strings are more like flags, there is a max of 3 flags. The list could be empty, if no flags apply, or it could contain only one or two flags. How can I separate out these flags into different GridView columns? Do I need to do it in the OnRowDataBound event?
Current, my aspx code looks something like this. I want to be able to change the ImageUrl of the Image controls based on if the flag is raised or not.
<asp:TemplateField HeaderText="Tax" SortExpression="Tax"> [code]....
I have a page grid.aspx which contains a rad grid, when a row is selected for update the user is redirected to another page where the he can update the row, after submitting the updates I want to redirect the user back to grid.aspx, but the grid displays that there are no records to display? When I navigate to another page and then go back to grid.aspx it works fine.
FYI: the update page doesn't use a data source, the item is retrieved and the form is filled manually. I used response.redirect("grid.aspx").
I have the following code
Imports System.Data
Partial Class Students_AddWishes
Inherits System.Web.UI.Page
Public dt As New DataTable
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
dt.Columns.Add("ID", System.Type.GetType("System.Int32"))
dt.Columns.Add("univirsity", System.Type.GetType("System.Int32"))
dt.Columns.Add("major", System.Type.GetType("System.Int32"))
End Sub
Protected Sub btnAdd_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAdd.Click
Dim row1 As DataRow = dt.NewRow()
row1("ID") = dt.Rows.Count + 1
row1("univirsity") = ddlUnivs.SelectedValue
row1("major") = ddlMajors.SelectedValue
dt.Rows.Add(row1)
GridView1.DataSource = dt
GridView1.DataBind()
End Sub
End Class
the problem is it shows only one row or record. How to make it shows many records?
I have an ASP page which displays a text box when it loads. It takes an input number, send it to the server through post back, and then displays some record in a grid view. After a number is input into the box, the server fetches some data from a database and add records to the grid view. It also contains a link column, whose URL is set to "#", so that the page isn't redirected when it is clicked.
Now I want to bind a jquery "click" event to that link. How can I do that ? I have tried that to do myself but failed, because it is not available when the DOM is loaded (since it only contains rows when a number is input through the box), and is being modified through ASP.NET Ajax post back.
the code is like,
namespace DataControlsSample.App_Code.PL
{
public partial class GridView : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
[Code]....
the data table is getting rows ,as i had chked ,,,but grid view is not getting displayed ..wat could be the problem?
I have an gridview consisting pager Templet. In pager templet, add first, previous,next and last Buttons to control records. PageSize is 3. First I am binding first 3 records from the list (Consisting 9 records) to the GridView.
My question is:
<1> Is it possible to bind the next 3 records(record4, record5,record6) to GridView when click on next Button?
<2> Similally, Is it possible to bind records for other buttons?
dynamic grid view loses binding when post back occurs ?
I have a dynamic grid View with template fields and bound fields as columns
for the first page load all binding looks fine.values are populated in all columns
when I trigger an event such as selected index changed in Drop downlist present in the column header(inside template field ) the binding are lost and the event is never catched.
how to retain controls when post back occurs and how to resolve this problem ?
I'm using the GetOleDbSchemaTable to get column info from an access db, column_name and description, but getting an error that the bind statement can't get the properties. I know its there because I can response.write it from its table, schemaTable.Rows(i)!DESCRIPTION.ToStringdo I have to bind it differently than when binding actual data from a table using the column name for reference?System.Web.HttpException: DataBinding: 'System.Data.Common.DataRecordInternal' does not contain a property with the name 'DESCRIPTION'.
View 2 Repliesas we all know
Dataset ds=new DataSet();
gridview1.datasource=ds;
when the dataset has no reccrds then the grid view will not displayed.
I need to show the grid with 10 rows with no details means empty records.
I am developing an application in C# and Sql Server.
View 3 RepliesI have to bind OData feed, which is a response from WCF Data Service, to a gridview. The structure is as follows:
[Code]....
[Code]....
this is my class
[code]....
hope my Question is clear.
I have no clue what I'm doing wrong here, but I wanted to create a grid view based on a return from a tableadapter.
[Code]....
[Code]....
Also, maybe I should be going about this another way as I wanted to add a drop down to each record and a link to each record.On pointers on how I should do this would be great too.
I am trying set up a simple dropdown list but I dont seem to be able to get it to bind to the Model. I am using Asp.Net MVC and nhibernate.
My dropdown list is declared like so:
<%= Html.DropDownListFor(model => model.Project, (IEnumerable<SelectListItem>)ViewData["Projects"], " -- Select -- ", new { name = "Project" })%>
I set up the select list like so:
ViewData["Projects"] = new SelectList(projectRepository.GetAll(), "EntityGUID", "Name", editEntity.Project);
This seems to bind the select list to the Dropdown fine, but the SelectedValue is not set.
it shows up as the default --- Select ---
Also when I save this data, the dropdown does not bind to the model, I have to manually set the object like so to save it:
entity.Project = projectRepository.GetById(new Guid(Request["Project"].ToString()));
I believe I have take the correct messures to have this item bind directly to my model. Is there something I am missing here?
I am working in asp.net 3.5 page, where I want to bind a textbox with generic list data. And I have Previous & next button. Which will show the record in textbox.
I don't want to go in db again and again.
I have a Drop Down List which I need to bind to the database. Here is the situation. I am not using a SQLDataSource. It is built on the n-tier application. The datasource of the dropdown is referring to a method in the C#class. That method has a generic array list which populates information into the arraylist. The Arraylist is the parameter that is returned to the DropDown List.
I have also set the Text property of the Drop down list
Text='<%DataBinder.Eval(Container.DataItem,"Employee_ID")%>'>
However, it is not populating the DropDown list, what should I do?
What do I use to set the dataValueField of the Select List when I'm using a list of strings. I want to be able to set the value of the option in the select. If i have:
List<string> list = new List<string>();
list.Add("apple");
list.Add("orange");
and I want my html to be:
<select>
<option value="apple">apple</option>
<option value="orange">orange</option>
</select>
I keep getting this error and i just can't figure it out:
The ViewData item that has the key 'CampaignId' is of type 'System.Int32' but must be of type 'IEnumerable<SelectListItem>'.
My Controller:
//show empty form
[AcceptVerbs(HttpVerbs.Get)]
public ViewResult Index(int? CampaignId)
[Code]....
I do need to have "CampaignId" in there because I'm populating some "partial views' based on this "CampaignId" that is selected (drop down)
I have a grid view which I am binding it through my .cs file code:
I need to hide a column, From the Below code I am able to hide the column but not the header and footer design.
So how can I hide my column when I dont have any columns in my gridview (I mean in .ASPX page)
MyCode:
[Code]....
.cs Code:
protected void Row_Grid(Object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Cells[9].Visible = false;
}
}
My Grid is bound to a collection type datasource. When I try to sort the Columns in the Grid I get Javascript error saying sorting event not implemented. Why is the default inbuilt sort functionality not working which worked fine when I directly used a sqlDataSource using smart tag. Do I have to write some code to achieve sorting ?
View 1 RepliesI am trying to bind the gererist list type to GridView control but for some reason its just displaying "Member"(Object name) rather then the actuakl content inside object.Any Idea why?Below i have decleared a List Type Member:
[Code]....
And the Below trying to bind with gridview:
[Code]....
I'll try and describe this issue, the best way I can. I have this concept binding one way (db binding) but it never seems to send the bound value back from any form controls (txbox etc).
I have a control which is basically a formview with bound controls. In this control, I have another nested control that has an innerproperty that can take 'templates' containing form controls i.e
[code]....
My problem is that the binding only works one way, the values are written to the controls inside the template (can be more than one) but the values never appear in the FormView.UpdateItem() > BoundFieldValues collection.