I'm trying to build several gridpanels with the result of a search in the DB.
But they never appears...
Here is my code, what's wrong with it ?
http://pastebin.com/WuTZwZrP
EDIT
Ok, got it. For those who have the same problem, I solved it by adding this to the GridPanel :
RenderTo = this.ExtPanel.ClientID
And this after the build :
ext.GridPanel grid = this.BuildGridPanel(forwarder.Key, forwarder.Value);
grid.Render();
//this.ExtPanel.Controls.Add(grid);
public void AddGridPanel()
{
Ext.Net.GridPanel g=new Ext.Net.GridPanel();
Ext.Net.Store store1=new Ext.Net.Store();
Model model = new Model();
for (int i = 1; i < tas.getTaskDE().Count / 2; i++)
{
fields = fields + "," + tas.getTaskDE()[i].FieldName;
ModelField modelField = new ModelField();
modelField.Name = tas.getTaskDE()[i].FieldName;
model.Fields.Add(modelField);
if (tas.getTaskDE()[i].Visibility == "true")
{
g.ColumnModel.Columns.Add(new ColumnBase[] {
new Column
{
Text = tas.getTaskDE()[i].FieldADName,
DataIndex = tas.getTaskDE()[i].FieldName,
Flex = 1
},
});
}
}
SqlDataSource s = new SqlDataSource();
s.ConnectionString =ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
s.SelectCommand = query;
store1.Model.Add(model);
store1.DataSource = s;
store1.DataBind();
g.Store.Add(store1);
g.Render(this.Form);
}
this an example of dynamic gridpanel hope it helps
Related
I am setting a CustomRoomProperties when a new game is started. Here:
public void startGame()
{
RoomOptions options = new RoomOptions();
options.CleanupCacheOnLeave = true;
options.MaxPlayers = 8;
options.IsOpen = true;
options.IsVisible = true;
Hashtable RoomCustomProps = new Hashtable();
RoomCustomProps.Add("availablePods", gameLenghtsIs);
options.CustomRoomProperties = RoomCustomProps;
PhotonNetwork.JoinOrCreateRoom(createInput.text, options, TypedLobby.Default);
}
And this is the RoomInfo displayed in the Lobby once a game is created:
public void SetRoomInfo(RoomInfo roomInfo)
{
RoomInfo = roomInfo;
maxPlayetTxt.text = roomInfo.MaxPlayers + ",";
nameRoomText.text = roomInfo.Name + ",";
payerNumberText.text = roomInfo.PlayerCount+ "/8";
}
To this RoomInfo i would want to add the created Custom Property but not really sure how. I tried:
podsTxt.text = roomInfo.CustomProperties["availablePods"] + ",";
This resulted in nothingness.
And i tried this:
podsTxt.text = roomInfo.CustomProperties["availablePods"].GetHashCode() + ",";
Resulted in a error.
Tried a few other things but can't get it to work.
P.S. I am using the Hashtable and the hastable does what it's sopposto to do. I would just want this value that i set at startGame()
"availablePods"
to bi displayed when getting the room list in the lobby.
Anyone can help?
If this help anybody, this is what wroked for me:
public void startGame()
{
RoomOptions options = new RoomOptions();
options.CleanupCacheOnLeave = true;
options.MaxPlayers = 8;
options.IsOpen = true;
options.IsVisible = true;
Hashtable RoomCustomProps = new Hashtable();
RoomCustomProps.Add("availablePods", gameLenghtsIs);
options.CustomRoomProperties = RoomCustomProps;
options.CustomRoomProperties.Add("availablePods", allPods);
options.CustomRoomPropertiesForLobby = new string[1] { "availablePods" };
PhotonNetwork.JoinOrCreateRoom(createInput.text, options, TypedLobby.Default);
}
Room Info:
public void SetRoomInfo(RoomInfo roomInfo)
{
RoomInfo = roomInfo;
maxPlayetTxt.text = roomInfo.MaxPlayers + ",";
nameRoomText.text = roomInfo.Name + ",";
payerNumberText.text = roomInfo.PlayerCount+ "/8";
podsTxt.text = roomInfo.CustomProperties["availablePods"].ToString();
}
Thanks to hijinxbassist, i got this working.
I'm trying to clear 3 TextView fields before new data is then displayed. I'm using SQLite and returning 3 phone numbers.
I can't run the app as I get "cannot convert from string to int" on the
txtFire.SetText("");
section of code.
The 3 fields in my SQLite DB are TEXT fields, so slightly confused on how to resolve this.
Any advice is appreciated.
private void EmergencyServicesData()
{
var location = FindViewById<AutoCompleteTextView>(Resource.Id.autoCompleteCountry).Text;
ICursor selectData = sqliteDB.RawQuery("SELECT POLICE, FIRE, MEDICAL FROM EmergencyServices WHERE COUNTRY = '" + location + "'", new string[] { });
if (selectData.Count > 0)
{
selectData.MoveToFirst();
do
{
txtFire = (TextView)FindViewById(Resource.Id.txtFire);
txtMedical = (TextView)FindViewById(Resource.Id.txtMedical);
txtPolice = (TextView)FindViewById(Resource.Id.txtPolice);
txtFire.SetText("");
txtMedical.SetText("");
txtPolice.SetText("");
EmergencyServices emergencyServices = new EmergencyServices();
EmergencyServices.Clear();
emergencyServices.POLICE = selectData.GetString(selectData.GetColumnIndex("POLICE"));
emergencyServices.FIRE = selectData.GetString(selectData.GetColumnIndex("FIRE"));
emergencyServices.MEDICAL = selectData.GetString(selectData.GetColumnIndex("MEDICAL"));
EmergencyServices.Add(emergencyServices);
}
while (selectData.MoveToNext());
selectData.Close();
}
foreach (var item in EmergencyServices)
{
LayoutInflater layoutInflater = (LayoutInflater)BaseContext.GetSystemService(Context.LayoutInflaterService);
View addView = layoutInflater.Inflate(Resource.Layout.EmergencyServices, null);
TextView txtPoliceData = addView.FindViewById<TextView>(Resource.Id.txtPolice);
TextView txtFireData = addView.FindViewById<TextView>(Resource.Id.txtFire);
TextView txtMedicalData = addView.FindViewById<TextView>(Resource.Id.txtMedical);
txtPoliceData.Text = item.POLICE;
txtFireData.Text = item.FIRE;
txtMedicalData.Text = item.MEDICAL;
container.AddView(addView);
}
}
You have nullpointers in your textviews. Change to this.
LayoutInflater layoutInflater = (LayoutInflater)BaseContext.GetSystemService(Context.LayoutInflaterService);
View addView = layoutInflater.Inflate(Resource.Layout.EmergencyServices, null);
txtFire = addView.FindViewById<TextView>(Resource.Id.txtFire);
txtMedical = addView.FindViewById<TextView>(Resource.Id.txtMedical);
txtPolice = addView.FindViewById<TextView>(Resource.Id.txtPolice);
I have created a telerik report using Visual Studio and set the Datasource from the DataTable. I am creating the columns dynamically at runtime using Telerik.Reporting.TableGroup. Now the problem I am having here is that the report showing the same data for all of the fields and when I debug it is setting different fields for different.
The code I am using is as follows:
private void Report4_NeedDataSource(object sender, EventArgs e)
{
DataTable dt = new DataTable();
dt = SalesReport.reportDataTable;
table1.DataSource = dt;
Telerik.Reporting.HtmlTextBox textboxGroup;
Telerik.Reporting.HtmlTextBox textBoxTable;
table1.ColumnGroups.Clear();
table1.Body.Columns.Clear();
table1.Body.Rows.Clear();
int ColCount = dt.Columns.Count;
for (int i = 0; i <= ColCount - 1; i++)
{
Telerik.Reporting.TableGroup tableGroupColumn = new Telerik.Reporting.TableGroup();
table1.ColumnGroups.Add(tableGroupColumn);
textboxGroup = new Telerik.Reporting.HtmlTextBox();
textboxGroup.Style.BorderColor.Default = Color.Black;
textboxGroup.Style.BorderStyle.Default = BorderType.Solid;
textboxGroup.Value = dt.Columns[i].ColumnName;
textboxGroup.Size = new SizeU(Unit.Inch(1.5), Unit.Inch(0.6));
tableGroupColumn.ReportItem = textboxGroup;
textBoxTable = new Telerik.Reporting.HtmlTextBox();
textBoxTable.Value = "=Fields." + dt.Columns[i].ColumnName;
textBoxTable.Size = new SizeU(Unit.Inch(1.1), Unit.Inch(0.3));
table1.Body.SetCellContent(0, i, textBoxTable);
table1.Items.AddRange(new ReportItemBase[] { textBoxTable, textboxGroup });
}
}
I suggest reading the following article. I found this same problem and my solution was to add unique names to the group column, label, and detail text boxes.
http://www.telerik.com/forums/incorrect-dynamic-table-columns
//Added
tableGroupColumn.Name = "group" + *something_uniquegoeshere*;
//Added
textboxGroup.Name = "label" + *something_uniquegoeshere*;
//Added
textBoxTable.Name = "data" + *something_uniquegoeshere*;
Not enough space in a comment unfortunately but here's my advice/suggestion. I'm not certain about your specific error, however in the past I have had issues when re-using variables. You declare your variable outside the for statement and it is possible that this is what is causing the problem.
private void Report4_NeedDataSource(object sender, EventArgs e)
{
DataTable dt = new DataTable();
dt = SalesReport.reportDataTable;
table1.DataSource = dt;
//Telerik.Reporting.HtmlTextBox textboxGroup;
//Telerik.Reporting.HtmlTextBox textBoxTable;
table1.ColumnGroups.Clear();
table1.Body.Columns.Clear();
table1.Body.Rows.Clear();
int ColCount = dt.Columns.Count;
for (int i = 0; i <= ColCount - 1; i++)
{
Telerik.Reporting.TableGroup tableGroupColumn = new Telerik.Reporting.TableGroup();
table1.ColumnGroups.Add(tableGroupColumn);
var textboxGroup = new Telerik.Reporting.HtmlTextBox();
textboxGroup.Style.BorderColor.Default = Color.Black;
textboxGroup.Style.BorderStyle.Default = BorderType.Solid;
textboxGroup.Value = dt.Columns[i].ColumnName;
textboxGroup.Size = new SizeU(Unit.Inch(1.5), Unit.Inch(0.6));
tableGroupColumn.ReportItem = textboxGroup;
var textBoxTable = new Telerik.Reporting.HtmlTextBox();
textBoxTable.Value = "=Fields." + dt.Columns[i].ColumnName;
textBoxTable.Size = new SizeU(Unit.Inch(1.1), Unit.Inch(0.3));
table1.Body.SetCellContent(0, i, textBoxTable);
table1.Items.AddRange(new ReportItemBase[] { textBoxTable, textboxGroup });
}
}
With ADO.net, if I want to retrieve the ID from combobox I just do such like this :
int idToGet = int.parse(tbCategory.SelectedValue.ToString());
Then done,
But when I bind the combobox with EF, it will show error Input string was not in a correct format. So the current value show { id = 7, category = TESTING } and not as usual.
Here a my code snippet :
public void loadCategory()
{
tbCategory.DataSource = null;
var listCategoryObj = new malsic_inventoryEntities();
var query = from cat in listCategoryObj.Category
//join cat in listItmObj.Category on n.id_category equals cat.id
select new { cat.id,cat.category };
if (query.Count() > 0)
{
tbCategory.DataSource = query.ToList();
tbCategory.DisplayMember = "category";
tbCategory.ValueMember = "id";
tbCategory.Invalidate();
}
else
{
tbSubCategory.Enabled = false;
}
}
public void loadSubcategory()
{
tbSubCategory.DataSource = null;
int id_category_current = int.Parse(tbCategory.SelectedItem.Value.ToString());
var listSubCategoryObj = new malsic_inventoryEntities();
var query = from SubCat in listSubCategoryObj.SubCategories
where SubCat.id_category == id_category_current
select new { SubCat.id, SubCat.subcategory };
if (query.Count() > 0)
{
groupBox1.Enabled = true;
tbSubCategory.DataSource = query.ToList();
tbSubCategory.DisplayMember = "subcategory";
tbSubCategory.ValueMember = "id";
tbSubCategory.Invalidate();
}
else
{
groupBox1.Enabled = false;
}
}
I do something wrong?
I don't think your problem is anything to with ADO.NET or Entity Framework. I think your problem is on the line with int.Parse. Try setting id_category_current this way instead of how you do it now:
int id_category_current;
if(!int.TryParse(tbCategory.SelectedItem.Value.ToString(), out id_category_current))
{
groupBox1.Enabled = false;
return;
}
I have the following code:
private void Timer1Tick(object sender, EventArgs e)
{
timer_ScanTimer.Enabled = false;
var psc = new ParseScannedCheckNumbers();
if (psc.ParseCheck(_checkData))
{
label_Status.Text = #"Scan Next Check";
var ct = checkTrans.IndividualCheck.NewIndividualCheckRow();
ct.Date = DateTime.Now.ToShortDateString();
var bracct = GetBranchAccountNumber(psc.BankAccountNumber);
if (bracct.Trim().Length == 7)
{
ct.Branch = bracct.Substring(0, 2);
ct.AccountNumber = bracct.Substring(2, 5);
ct.NameOnCheck = GetAccountName(ct.Branch + ct.AccountNumber);
ct.AccountBalance = GetAccountBalance(ct.Branch + ct.AccountNumber);
}
else
{
ct.Branch = Configuration.Branch;
ct.AccountNumber = string.Empty;
ct.NameOnCheck = string.Empty;
ct.AccountBalance = 0;
}
ct.CheckAmount = 0;
ct.BankRoutingNumber = psc.BankRoutingNumber;
ct.BankAccountNumber = psc.BankAccountNumber;
ct.CheckNumber = psc.CheckNumber;
ct.Status = "Entered";
checkTrans.IndividualCheck.Rows.Add(ct);
}
else
{
label_Status.Text = Resources.ScanCheck_ScanFailed;
}
_checkData = string.Empty;
var rs = new RegistrySettings();
if (!rs.ScanChecksContinuous)
{
StopScanning();
label_Status.Text = Resources.ScanCheck_Success;
EditLastRowEntered();
}
label_ChecksScanned.Text = (dgv_Checks.RowCount - 1).ToString();
}
When the timer goes off, I verified that I have received all of the data, then I add it to the dataset. It's being added to the dataset without issue, it's just being seen on the datagridview every time. Sometimes it works, most time it doesn't.
How do I get the datagridview to update when changes are done to the dataset? Am I doing something wrong in the above code?
Thanks! (again)
If you created the dataset and attached it to the DataGridView using the Visual Studio Data Source Configuration Wizard, then you probably have a call to
this.somethingTableAdapter.Fill(this.yourDataSet.someDataTable);
somewhere in your code. This is what actually loads the data from the DataSet into your DataGridView. While calling this method again might not be the 'proper' way to refresh your DGV, it did the job for me.