473,396 Members | 1,872 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

the error shows that cannot implicit int type to bool value

the error shows that cannot implicit convert type 'System.Data.SqlClient.SqlParameter' to 'bool'..

here is my code ...


code:


protected void GridView1_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
{
cmd.CommandType = CommandType.TableDirect;
DropDownList id = (DropDownList)sender;

// e.NewSelectedIndex["Status"] = (Convert.ToString()id.SelectedValue;

// GridViewRow row = GridView1.Rows[GridView1.EditIndex];
GridViewRow row = GridView1.Rows[GridView1.SelectedIndex];

cmd.CommandType = CommandType.TableDirect;
if(cmd.Parameters.AddWithValue("@Status", txtslry.Text))
{
txtslry.Text = "Yes";

if (id.SelectedValue == "Yes")
{
TextBox column1 = (TextBox)row.FindControl("Column1ID");
column1.Visible = true;
TextBox column2 = (TextBox)row.FindControl("Column2ID");
column2.Visible = true;
TextBox column3 = (TextBox)row.FindControl("Column3ID");
column3.Visible = true;
TextBox column4 = (TextBox)row.FindControl("Column4ID");
column4.Visible = true;
TextBox column5 = (TextBox)row.FindControl("Column5ID");
column5.Visible = true;



}

else if (cmd.Parameters.AddWithValue("@Status", txtslry.Text))
{
txtslry.Text = "No";
}
else if (id.SelectedValue == "No")
{
TextBox column1 = (TextBox)row.FindControl("Column1ID");
column1.Visible = false;
TextBox column2 = (TextBox)row.FindControl("Column2ID");
column2.Visible = false;
TextBox column3 = (TextBox)row.FindControl("Column3ID");
column3.Visible = false;
TextBox column4 = (TextBox)row.FindControl("Column4ID");
column4.Visible = false;
TextBox column5 = (TextBox)row.FindControl("Column5ID");
column5.Visible = false;


}
Apr 9 '12 #1
1 2084
Monomachus
127 Expert 100+
The problem is in your ifs statements cmd.Parameters.AddWithValue will return a System.Data.SqlClient.SqlParameter, but you want somehow to decide base on it (meaning you want to see a boolean ? ).
Check more about SqlParameter.AddWithValue in http://msdn.microsoft.com/en-us/libr...withvalue.aspx
Expand|Select|Wrap|Line Numbers
  1. if(cmd.Parameters.AddWithValue("@Status", txtslry.Text))
  2. {
  3.  
Apr 9 '12 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: Johan | last post by:
Hi Can somebody explain to me why I get this warning message and how I can solve this warning message. Thanks a lot Johan In member function `void
3
by: Jon Shemitz | last post by:
Why would you ever want to define both "public static bool operator true" and "public static bool operator false" when you can just define "public static implicit operator bool"? Is there syntax...
2
by: Jon Shemitz | last post by:
How come I can write code like "if (L)" but NOT code like "if (L == true)" when L is a class with an implicit operator bool? /////////// List L = new List(); public class List { private...
6
by: Tim Cartwright | last post by:
I have a page that has the login control on it, nothing else. This page inherits from a master page, neither page has any code in it. This page works perfectly when running on the WebDev debug web...
2
by: Paul Hemans | last post by:
I am very new at .Net. I have a small project where I need to manipulate the contents of a web page. I have a form with a web browser control (webBrowser1) on it. Within the...
2
by: Marcelo Muzilli | last post by:
Howdy all, in my program, I have a ushort variable and a string variable and if I try to compile it, I'm receiving this error message: "Cannot convert type 'string' to 'ushort'". How can I...
6
by: John | last post by:
The following code: int test = 1; bool isTrue = (bool)test; results in a compiler error: Cannot convert type 'int' to 'bool' wtf, any ideas on how to work around this?
1
by: KamalaChandru | last post by:
i got an error "cannot covert the type double to type bool.
2
by: Paulo | last post by:
DataRow dr = (DataRow)ds.Tables.Rows.ItemArray; Error 1 Cannot convert type 'object' to 'System.Data.DataRow' C:\Documents and Settings\Fabio\Meus documentos\Visual Studio...
2
by: nomad | last post by:
Hi, When trying to serialize a class I keep getting the message below. optionalExtensionTypeOptionalExtension is not mandatory so not sure why this is appearing. If anyone has seen this type...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.