|
SqlConnection cn = new SqlConnection(@"");
string []Sel=new string[3];
int Cnt;
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
SqlCommand cmd = new SqlCommand("Select * from color", cn);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds, "color");
string d;
for (int i = 0; i <= ds.Tables[0].Rows.Count - 1; i++)
{
for (int j = 1; j <= ds.Tables[0].Columns.Count-1; j++)
{
d = ds.Tables[0].Rows[i].ItemArray[j].ToString();
Sel = d.Split(new Char[] { ',' });
Cnt = Sel.Length;
switch (j)
{
case 1:
{
multchk(chk1, chk2, chk3, Sel);
break;
}
case 2:
{
multchk(chk4, chk5, chk6, Sel);
break;
}
}
}
}
}
protected void multchk(CheckBox ch1,CheckBox ch2,CheckBox ch3,string []str)
{
if (Cnt==1)
{
if (str[0] == "1")
ch1.Checked = true;
if (str[0] == "2")
ch2.Checked=true;
if (str[0] == "3")
ch3.Checked = true;
}
if (Cnt==2)
{
if (str[0] == "1" || str[1] == "1")
ch1.Checked = true;
if (str[0] == "2" || str[1] == "2")
ch2.Checked = true;
if (str[0] == "3" || str[1] == "3")
ch3.Checked = true;
}
if (Cnt==3)
{
if (str[0] == "1" || str[1] == "1" || str[2] == "1")
ch1.Checked = true;
if (str[0] == "1" || str[1] == "2" || str[2] == "3")
ch2.Checked = true;
if (str[0] == "1" || str[1] == "2" || str[2] == "3")
ch3.Checked = true;
}
}
protected void singchk(CheckBox ch1,CheckBox ch2,string []str)
{
if (str[0] == "1")
ch1.Checked = true;
if (str[1] == "2")
ch2.Checked = true;
}
|
|
|
|
|
This is the worst code I've seen in a long time. SO many things wrong with it. If someone I paid wrote this, I'd fire them. In fact, there's no way I'd have hired them.
Your checkboxes are called chk1, chk2, chk3, chk4, chk5, and chk6 ? Are you hoping for future outsourcing work on the basis that your code is unreadable ?
JAS GIRI wrote: string d;
for (int i = 0; i <= ds.Tables[0].Rows.Count - 1; i++)
{
for (int j = 1; j <= ds.Tables[0].Columns.Count-1; j++)
{
d = ds.Tables[0].Rows[i].ItemArray[j].ToString();
You create d outside the loop but only use it inside. you use <= x-1 instead of < x, you start j from 1 instead of 0 ( is that right ), you use i and j instead of meaningful names, what a mess.
JAS GIRI wrote: protected void multchk(CheckBox ch1,CheckBox ch2,CheckBox ch3,string []str)
{
if (Cnt==1)
{
if (str[0] == "1")
ch1.Checked = true;
if (str[0] == "2")
ch2.Checked=true;
if (str[0] == "3")
ch3.Checked = true;
}
if (Cnt==2)
{
if (str[0] == "1" || str[1] == "1")
ch1.Checked = true;
if (str[0] == "2" || str[1] == "2")
ch2.Checked = true;
if (str[0] == "3" || str[1] == "3")
ch3.Checked = true;
}
if (Cnt==3)
{
if (str[0] == "1" || str[1] == "1" || str[2] == "1")
ch1.Checked = true;
if (str[0] == "1" || str[1] == "2" || str[2] == "3")
ch2.Checked = true;
if (str[0] == "1" || str[1] == "2" || str[2] == "3")
ch3.Checked = true;
}
}
The logic surrounding Cnt is poorly implemented. Again, it's like you're trying to write spaghetti code.
Perhaps if you in one place posted your crappy code, some notes as to what you're trying to do, an explanation of the data you're using, why you can't use a checkboxlist, and what exactly this code does, as opposed to what you expect it to do, perhaps then someone who feels like doing your job for you, might have what they need in order to help. If you fail to do this in the next day, then I'd suggest you're beyond any sort of help, and should just give up.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Is there MS SQL database server in visual studio 2008? or we have to setup it separately?
|
|
|
|
|
I am not sure, but I think express version will be installed with VS. BTW, how this question is in ASP.NET forum?
|
|
|
|
|
Hi
When i tried to debug my web application the above is coming
|
|
|
|
|
I don't see how you expect anyone to be able to help you based on this. Tell us exactly what is happening, what you've tried to fix it, what your setup is, etc.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Hi,
I have a Dictionary<string,> object that uses the Item name as the Key (string) and Size as the Item (decimal). However, on some occasions, the Item name repeats itself, but the itemIDs are always unique. So, I want to switch my Dictionary<string,> to be Dictionary<int,decimal>. My problem occurs when I am trying to get items that are checked from the datagrid. Right now this is the code:
public void GetChecked()
{
Dictionary<string,decimal> Checked=(Dictionary<string,decimal> )Session["CheckedItems"];
string itemname;
CheckBox cb;
TextBox tb;
if (Checked !=null)
{
foreach (GridViewRow gvRow in gvwItems.Rows)
{
itemname= gvRow.DataKeys[row.RowIndex].Value.ToString();
if(Checked.ContainsKey(itemname))
.
.
.
.
How do I alter this code to read the item_id which is an integer and not a string?
Please help if you can, I am very stuck on this and do not know how to proceed.
Thank you.
|
|
|
|
|
Dictionary<int,decimal> Checked=(Dictionary<int,decimal> )Session["CheckedItems"];
int itemname;
CheckBox cb;
TextBox tb;
if (Checked !=null)
{
foreach (GridViewRow gvRow in gvwItems.Rows)
{
itemname= Convert.ToInt32(eRow.DataKeys[row.RowIndex].Value.ToString());
if(Checked.ContainsKey(itemname))
...
...
...
|
|
|
|
|
I made the changes you suggested and am now getting the following error:
A first chance exception of type 'System.Threading.ThreadAbortException' occurred in mscorlib.dll
An exception of type 'System.Threading.ThreadAbortException occurred in mscorlib.dll but was not handled in user code
A first chance exception of type 'System.FormatException' occurred in mscorlib.dll
How do i fix this?
|
|
|
|
|
Does it tell you at which line the exception occurred?
|
|
|
|
|
how to use session method in an application
|
|
|
|
|
Have a look here[^]
Calin
|
|
|
|
|
if u ask the same question to google ,you were able to get the answer instantly in that time.U wasted ur and other's time
|
|
|
|
|
i have store data use check box selected in text
how cant retrieve data in check box retrieve time fill the check box selected with find own text
like
store database text in mango
fruits banana[] mango[,] orange[]
|
|
|
|
|
Wow
We all know that English is not our First Language some of us , but atleast try not to write what you dont know. Can you please use the Basic English. I cant really Figuire out what you are trying to say. Can you please explain again, this time take your time.
Thank you
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.tiyaneProperties.co.za
vuyiswa@its.co.za
www.ITS.co.za
|
|
|
|
|
You have been asking the same question for DAYS. Are you stupid ? Have you written any code at all ? Did you try reading some articles here on code project or generally on the web ? Is someone paying you day after day to play solitaire and wait for someone here to decipher your repeated posts and do your job for you ?
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
|
Seriously, this guy has probably got a job at a place that got the work b/c it was 1/10 the cost of hiring people in the West. And, that's fine, but, they are that cheap b/c they have no idea how to do their jobs. I don't mind helping people, regardless of where they are or what they are coding for, but I assume a basic level of ability, and willingness to learn. I sure expect some thought to be put into a question, instead of the same thing being posted day after day.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Yes, you have right.
Calin
|
|
|
|
|
Hi all,
I have a query to make.I have created a website in VS2005.I wish to publish it on IIS 5.1 which is on another PC on the network.But that PC has VS2003(instead of VS2005).Is there a way to publish my website on that IIS?Further my query stays the same for IIS 6.0.Please help.My delivery date is drawing nearer and m under immense pressure.
|
|
|
|
|
Publishing has nothing to do with the Vesrion of the VS.
When you are done and satisfied that your Application is working fine. Go to that PC with IIS5 and Create a Virual Directory and paste those Files there. Go to your IIS Configure some settings that you will need
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.tiyaneProperties.co.za
vuyiswa@its.co.za
www.ITS.co.za
|
|
|
|
|
Thanks for your help..I think now I can work easily..
|
|
|
|
|
Glad be at your service
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.tiyaneProperties.co.za
vuyiswa@its.co.za
www.ITS.co.za
|
|
|
|
|
Hi. I am trying to retrieve the text of a textbox from code behind after setting the text via javascript (JS) on the page itself.
I do it like this via JS on a html radiobutton event:
var provider = document.getElementById('<%=txtMailProvider.ID %>');
provider.value = '@blah.com';
I then try to get that text from the txtbox on a server button click event, in code like:
string blah = txtMailProvider.Text; this bring back and empty string.
Is there another, working, way to do this? Tried google, etc
Any help would be great.
Thanks
M
|
|
|
|
|
is '@blah.com' still in the textbox after you press button?
|
|
|
|