defaultview not returning all rows - asp.net

I have a dataset. it has 32 rows.I am not applying any rowfilter to it.code is here
private void SetPageNumbers(DataSet dsQuestion)
{
DataView dv = dsQuestion.Tables[0].DefaultView;
}
It is showing only 4 rows in dv.
But I want all rows. What can be the reason behind it?
I also noticed that defaultview is showing Rowfilter as "SectionId=4".But I have defined this in another function.

Try this
private void SetPageNumbers(DataSet dsQuestion)
{
DataView dv = new DataView(dsQuestion.Tables[0]);
}

I done it by adding following line;
dtques.DefaultView.RowFilter = string.Empty;
Can anyone answer why Defaultview got its value in different function. Is it attached to dataset.

Related

Devexpress - Re-bind Chart Control error Index was out of range

I has using dexexpress chartcontrol and bind the datasource in runtime.
chartControl1.DataSource = ds.Tables[0];
chartControl1.SeriesDataMember = "Task";
chartControl1.SeriesTemplate.ArgumentDataMember = "Resource";
chartControl1.SeriesTemplate.ValueDataMembers.AddRange(new string[] { "Percentage" });
chartControl1.SeriesTemplate.View = new StackedBarSeriesView();
The first time binding, it has work fine and can show the chart.
When I click a button to re-create the dataset with new row of data, it give me an error in
chartControl1.DataSource = ds.Tables[0];
I has set the dataset = new dataset before fill it again with new data.
Any one has idea what wrong. Please help.
You should be able to do something along the lines of the following:
this.chartControl1.BeginInit();
DataTable chartData = this.chartControl1.DataSource as DataTable;
DataRow row = new DataRow()
{
"col1",
"col2"
}
chartData.Rows.Add(row);
this.chartControl1.RefreshData();
this.chartControl1.EndInit();
I hope this is helpful.
I have found that DevExpress occasionally gets confused when I set the DataSource, especially to an existing object. To work round this, before I set the DataSource to anything, I always set it to null first. Since doing that, I have not had any problems.
Give that a try.

DataGrid column value not showing with labelFunction

I have a Spark DataGrid that I'm using a labelFunction with. However it's not showing any results.
var c3:GridColumn = new GridColumn("Date Added");
c3.width = 150;
//c3.dataField = "date";
c3.labelFunction = getFormattedDateNoTimeGrid;
public function getFormattedDateNoTimeGrid(item:Object, column:GridColumn):String
{
var rawDate:String = item.date;
trace("Date:" + rawDate);
return rawDate;
}
With the previous code it shows nothing but the label function is called and all the dates correctly trace out. If I remove the dateField line the column is not empty but it's not the value returned by the label function. Basically the label function is not showing the value it is supposed to.
What a pain. Flash Builder "helped" me create a item renderer for my grid column that had this function in it:
override public function prepare(hasBeenRecycled:Boolean):void {
lblData.text = data[column.dataField];
}
That function overrides the functionality of the dataField and labelFunction. I removed it and all is well. Thanks everyone for all your help.

CheckEdit as XtraGrid Column

edit = gridView1.GridControl.RepositoryItems.Add("CheckEdit") as RepositoryItemCheckEdit;
column = gridView1.Columns.Add();
column.OptionsColumn.AllowSort = DevExpress.Utils.DefaultBoolean.False;
column.VisibleIndex = 0;
column.FieldName = "CheckMarkSelection";
column.Caption = "Mark";
column.OptionsColumn.ShowCaption = false;
column.UnboundType = DevExpress.Data.UnboundColumnType.Boolean;
edit.NullStyle = StyleIndeterminate.Unchecked;
column.ColumnEdit = edit;
I suppose I succeed in adding a checkedit column into gridview but i still can't check multiple rows and can't access edit's check state. Why? i ll be appreciated, because i have been struggling with this for 3 days
Use the designer of the gridview. Goto columns, select the column you would like to be a checkedit. Go to ColumnEdit and select a checkedit. Then you really should be able to check multiple rows for this editor. Multiselect (selecting multiple rows simultaneously) is in the OptionsBehavior I guess. When I'm at work (tomorrow) I can provide you with a sample. It can't be very difficult that's for sure.
The problem appears because the column is marked as unbound. In this case, the GridView generates the CustomUnboundColumnData event which can be used to provide data to this column and save it. I think you should handle this event to resolve the original problem.
In the GridDesigner, for CheckEdit, set "NullStyle" property to "Unchecked", and for the column that you are going to use for CheckEdit, set "FieldName" property to the name of your column in the datatable (I used "col1" for boolean values true,false). After you set everything at the GridDesigner, you have to declare a type for the columns. For example i used a code like this;
public DataTable datas = new DataTable();
private void Form1_Load(object sender, EventArgs e)
{
datas.Columns.Add("col1", typeof(bool));
datas.Columns.Add("col2", typeof(string));
datas.Columns.Add("col3");
gridControl.DataSource = datas;
}
datas.Rows.Add(False, "someValue", "");
datas.Rows.Add(False, "someValue", "");
datas.Rows.Add(True, "someValue", "");
datas.Rows.Add(False, "someValue", "");
Than it should work. I hope it is the solution of your problem. Thanks.

Error in ASP.NET C# (implicit conversion)

I am new in ASP.NET programming. Please help me.
void DisplayData()
{
DataTable dt = new DataTable();
//objBuyer.BuyerId = Convert.ToInt64(Request.QueryString["id"]);
**ERROR-->>>** dt = objBuyer.DisplayData();********
if (dt.Rows.Count > 0)
{
txtBName.Text = dt.Rows[0][1].ToString();
ERROR:Cannot implicitly convert type 'void' to 'System.Data.DataTable'
You are trying to convert void to a DataTable, which is not possible. Your method has to return a DataTable for this to work.
The problem is that the DisplayData method does not return a DataTable object, it simply displays the data in objBuyer, and returns void.
That's the problem, but I can't really help further than that without some sort of context!
The DisplayData() method needs to return a DataTable in order for this to work.
A nice and easy tutorial can be found here: http://www.aspnettutorials.com/tutorials/controls/data-table-csharp.aspx
As you can see, there's a DataTable created and after that's done, several rows are added to the table with the Rows.Add() method.

Non-null variable is being called null?

protected var categoryXML:XML;
protected var categoryArr:ArrayCollection;
protected var categoryList:IList;
for (var i:int=0;i<getLength(categoryXML.category);i++) {
trace(categoryXML.category[i].name);
categoryArr[i] = categoryXML.category[i].name;
}
I'm having trouble with this bit of code...
The trace here works great, and I get the response I expect, but when I try to add it to the categoryArr variable, I get yelled at and told it's null.
What could cause the difference here?
Thanks!
did you try to create your ArrayCollection : categoryArr = new ArrayCollection(); ?
So, if you are getting that there is a null reference at that line, it is because categoryArr is probably null. You need to initialize it, like #www0x0k suggested.
I will also suggest that you probably don't want to use indexes in this way. It assumes too much about the length of the particular ArrayCollection without any bounds checking. Consider code like this instead:
categoryArr = new ArrayCollection();
for each(var category in categoryXML.category) {
trace(category.name);
categoryArr.addItem(category.name);
}

Resources