how to replace dbk,depb,epcg,nfei with Demo[i]? [closed] - c#

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
here is my code i want to replace dbk,depb,epcg,nfei with Demo[i]
string Test = ddlExim.SelectedItem.Text.Substring(3);
txtEximDesc.Text = ddlExim.SelectedItem.Text.Substring(3);
string[] Demo = ddlExim.SelectedValue.Split(',');
DBK.Style.Add("display", "none");
DEPB.Style.Add("display", "none");
EPCG.Style.Add("display", "none");
NFEI.Style.Add("display", "none");
for (int i = 0; i < 3; i++)
{
if (Demo[i] == "DEPB")
{
DEPB.Style.Add("display", "table-row");
}
}
}

If I understand your problem correctly then I think the simplest way would be adding a switch case. Check the code below. Please elaborate your question if this is not what you meant.
for (int i = 0; i < Demo.Length; i++)
{
switch (Demo[i].ToLower())
{
case"dbk":
DBK.Style.Add("display", "table-row");
break;
//And so on
default:
break;
}
}
OR
mark runat="server" to the table element inside which these tablerows are present ("tbl" in my example) and then try the following code.
for (int i = 0; i < Demo.Length; i++)
{
(tbl.FindControl(Demo[i]) as HtmlTableRow).Style.Add("display", "table-row");
}
Of course you need to add the following namespace.
using System.Web.UI.HtmlControls;
Hope this helps.

Related

C# for loop need some help here - closed [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I think my loop have some problem. First i consider (i=0 and i>1) but i have no idea how to write. Any one can help me?
logik i want is
//start
=>if i=0 copy from txtbox1;
=>after that, compare i=2 and i=3 see whether are same. if same then copy from txtbox;
=>i++ until the last, every 1,2,3,4... will show differend string;
//end
public void OnMasterColumnChanged(BCE.AutoCount.Invoicing.Sales.SalesOrder.SalesOrderMasterColumnChangedEventArgs e)
{
for (int i = 0; i < e.MasterRecord.DetailCount; i++)
{
if (i == 0)
{
e.MasterRecord.GetDetailRecord(i).YourPONo = TxtBox1.Text;
}
else if (i > 1)
{
if (e.MasterRecord.GetDetailRecord(i).YourPONo == e.MasterRecord.GetDetailRecord(i - 1).YourPONo)
{
e.MasterRecord.GetDetailRecord(i).YourPONo = TxtBox1.Text;
}
}
}
}
I think that you want that:
public void OnMasterColumnChanged(BCE.AutoCount.Invoicing.Sales.SalesOrder.SalesOrderMasterColumnChangedEventArgs e)
{
if (e.MasterRecord.GetDetailRecord.Count == 0)
return;
e.MasterRecord.GetDetailRecord(0).YourPONo = TxtBox1.Text;
if (e.MasterRecord.GetDetailRecord.Count < 3)
return;
for (int i = 2; i < e.MasterRecord.DetailCount; i++)
{
if (e.MasterRecord.GetDetailRecord(i).YourPONo == e.MasterRecord.GetDetailRecord(i - 1).YourPONo)
{
e.MasterRecord.GetDetailRecord(i).YourPONo = TxtBox1.Text;
}
}
}
IF GetDetailRecord method returns the different values for different inputs then You are passing the different values below for the GetDetailRecord and checking the equal condition.
if (e.MasterRecord.GetDetailRecord(i).YourPONo == e.MasterRecord.GetDetailRecord(i - 1).YourPONo)
At one place you are passing GetDetailRecord(i) and checking with the GetDetailRecord(i - 1)

How can I get value in values of item of checkboxlist ? c# [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
I want to match the values from reader and checkbox to change selected values of item of checkboxlist. But it does not work and I don't know what to do? Thanks.
while (reader.Read())
{
CheckBoxList1.Items.FindByValue(reader["malzeme_id"].ToString()).Selected = true;
}
I tried also,
while (reader.Read())
{
for (int i = 0; i < CheckBoxList1.Items.Count; i++)
{
if (CheckBoxList1.Items[i].Value.Equals(reader["malzeme_id"].ToString()))
{
CheckBoxList1.Items[i].Selected = Convert.ToBoolean( reader["isSelected"]);
}
}
This is the first thing i found when I googled how to programaticly select a item in the list.
Assuming that the items in your CheckedListBox are strings:
for (int i = 0; i < checkedListBox1.Items.Count; i++)
{
if ((string)checkedListBox1.Items[i] == value)
{
checkedListBox1.SetItemChecked(i, true);
}
}
Or
int index = checkedListBox1.Items.IndexOf(value);
if (index >= 0)
{
checkedListBox1.SetItemChecked(index, true);
}
This awnser was found on this post, and posted by wdavo.

Linq query converting to bool? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
How Can I get a bool back from the below linq query? I need to compare each deal target property and totalDealsCompleted property and if any deal targets are less than the total deals completed then set HasEachTeamMemberHitTarget to false.I get a an error when building the below code on the if statment. I'm doing this in c#, mvc.
for (int i = 0; i < this.Select(m => m.EmployeeID).Count(); i++)
{
if (this.Select (m => m.DealTarget < m.TotalDealsCompleted))
{
HasEachTeamMemberHitTarget = false;
break;
}
else
{
HasEachTeamMemberHitTarget = true;
}
}
Is this what you want?
HasEachTeamMemberHitTarget = this.All(m => m.DealTarget < m.TotalDealsCompleted);

Autonumber with alternating number and letters [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I want an auto-numbering class in c# which would generate numbers of 8 digit length in the following format i.e. 1A2B3C4D..one number followed by one letter.Any suggestions??
Pseudocode for generating such string:
String result = "";
for ( int i = 0; i < 8 ; i++)
{
if ( i % 2 == 0)
{
// random(a,b) returns random value between or equal to a-b
result.append(random(0,9).toString());
}
else
{
result.append(random(65,90).toChar()); // Generating a random value between 65-90 (A-Z in ascii)
}
}
Edit:
Or as Sayse suggested:
String result = "";
for (int i = 0; i< 4; i++)
{
result.append(random(0,9).toString());
result.append(random(65-90).toChar());
}

Arrays In loops by C# [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I want to make a lot of array in for loops by C# like below: please help me!
for(int i=1;i<10;i++)
{
int[][] a+i=new int[10][3];
}
IMO, best will be to use a Dictionary<string,int[][]>.
During creation you will place a new array (which you just created) and assosiate it to the key "a" + i.
To get this array, just get the value attached to the relevant key.
Something like (C#-like pseudo code):
var map = new Dictionary<string,int[][]>();
for(int i=1;i<10;i++)
{
var temp = new int[10][3];
map["a" + i] = temp
}
and to get a value just use map[key] (for example map["a7"] will get the 7th element).
A good alternative would be to use a 3D array.
You are probably trying to create jagged arrays. Here's how you can do it:
var a = new int[10][];
for (var i = 0; i < a.Length; i++)
a[i] = new int[3];
for (var i = 0; i < a.Length; i++)
for (var j = 0; j < a[i].Length; j++)
a[i][j] = 1; // Initialize with your values

Categories