|
No the table has only one row and the procedure returns only one boolean value.
Thanks
Leonidas Kallis
|
|
|
|
|
Hi,
Then it is not necessary to use reader.
You can create a procedure that will return the values u need and then you those values as per your requirement.
In the procedure you can write selecte statements for all the tables and the assing the values to the output parameters.
By this way you will not need to write the same code again and again and only one procedure will do all your work.
Thanks and Regards,
Chetan Ranpariya
|
|
|
|
|
Hi,
I hope the following solution will help you.
You create a common event handler for the command event of all your switchbuttons.
public void bttns_command(object sender, CommandEventargs e)
{
if(e.CommandName == "Switch1")
{
//do work related to switch1;
if(Label1.Text == "ON")
{
query = "Update ..........."
ChangeButton("Switch1",0);
}
else
{
query = "update............."
ChangeButton*("Switch1",1);
}
updateCMD = New SqlCommand(query, SQLconn)
updateCMD.CommandType = CommandType.Text
SQLconn.Open()
updateCMD.ExecuteNonQuery()
SQLconn.Close()
}
else if(e.CommandName == "Switch2")
{
if(Label2.Text == "ON")
{
query = "Update ..........."
ChangeButton("Switch2",0);
}
else
{
query = "update............."
ChangeButton*("Switch2",1);
}
updateCMD = New SqlCommand(query, SQLconn)
updateCMD.CommandType = CommandType.Text
SQLconn.Open()
updateCMD.ExecuteNonQuery()
SQLconn.Close()
}
else if(e.CommandName == "Switch3")
{
if(Label3.Text == "ON")
{
query = "Update ..........."
ChangeButton("Switch3",0);
}
else
{
query = "update............."
ChangeButton*("Switch3",1);
}
updateCMD = New SqlCommand(query, SQLconn)
updateCMD.CommandType = CommandType.Text
SQLconn.Open()
updateCMD.ExecuteNonQuery()
SQLconn.Close()
}
}
The html for your buttons should look like following.
<asp:Button id="bttnSwitch1" Runat="server" CommandName = "Switch1"
OnCommand="bttns_command"></asp:Button>
<asp:Button id="bttnSwitch2" Runat="server" CommandName = "Switch2"
OnCommand="bttns_command"></asp:Button>
<asp:Button id="bttnSwitch3" Runat="server" CommandName = "Switch3"
OnCommand="bttns_command"></asp:Button>
Now you ChangButton function shuld look like following:
private void ChangeButton(string switchname, bool status)
{
if(switchname == "Switch1")
{
if(status)
{
Label1.Text = "ON";
OnOff1.Style.Value = "background-image: url(../ImgContr/1.png);"
}
else
{
Label1.Text = "OFF"
OnOff1.Style.Value = "background-image: url(../ImgContr/2.png);"
}
}
else if(switchname == "Switch2")
{
if(status)
{
Label2.Text = "ON";
OnOff2.Style.Value = "background-image: url(../ImgContr/1.png);"
}
else
{
Label2.Text = "OFF"
OnOff2.Style.Value = "background-image: url(../ImgContr/2.png);"
}
}
else if(switchname == "Switch3")
{
if(status)
{
Label3.Text = "ON";
OnOff3.Style.Value = "background-image: url(../ImgContr/1.png);"
}
else
{
Label3.Text = "OFF"
OnOff3.Style.Value = "background-image: url(../ImgContr/2.png);"
}
}
}
I hope this will help you.
Thanks and Regards,
Chetan Ranpariya1
|
|
|
|
|
Thank you very much...
I will study the above code and see what I can do...
|
|
|
|
|
Hi,
My form contains only Textbox and Button.I have a string variable in cs file and HTML TextField in aspx page. Str I have a value i am placing Request.Querystring().So I need javascript validation like this
user Should not Enter the value that String value contains.Pls tell me syntax in javascript.
Thanks
|
|
|
|
|
You would do better to render the value as a variable in javascript. Then your textbox should contain an onblur that checks if it's text equals this variable.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Sure,
and just to complement Graus sugestion, you can get that variable in your URL using a Javascript QueryString method (search for it) in the onload event of your page`s body.
|
|
|
|
|
How can we use web parts as in like >> have a look at this site
http://www.pageflakes.com (asp.net 2.0 )
|
|
|
|
|
|
Hi
ALL of you.
i use view state for sorting code is given but problem
is that it sorts perfectly on name but not on date ..
What to do????
actually i chage the date into varchar in order to display in drid
For Ex it shows 01 Feb 2007 in Grid but when i click on header it
dont sort in correct way..
<br />
<br />
Bind();<br />
oColumnCollection=dgHistory.Columns;<br />
if(ViewState["SortOrder"].ToString() == "" || ViewState["SortOrder"].ToString() == "DESC")<br />
{<br />
dv.Sort = e.SortExpression;<br />
<br />
ViewState["SortExpression"]= e.SortExpression + "ASC";<br />
ViewState["SortOrder"] = "ASC";<br />
}<br />
else<br />
{ <br />
dv.Sort = e.SortExpression + " DESC";<br />
<br />
ViewState["SortExpression"]= e.SortExpression + " DESC";<br />
ViewState["SortOrder"] = "DESC";<br />
}<br />
<br />
dgHistory.DataBind();<br />
Thanks
|
|
|
|
|
For date sorting, you have to use some different logic, especially date sorting is the best one. But, here you are using just string sorting, so you won't get correct result.
So, use date field in the dataview instead of changing into varchar (that is best way), and use format to display the date into the specified format. You can use the DataFormatString property in grid.
For example: for bound column,
....asp:BoundColumn DataField="FieldName" DataFormatString="{0:dd MMM yyyy}" .....
I hope, you can get the answer from this.
Regards
R.Arockiapathinathan
|
|
|
|
|
Hi,
Do not covnert you date column to varchar but set the DataFormatString property of the column in which you are displaying the date value.
Design Time
<asp:BoundColumn DataField="colName" DataFormatString = "{0:dd-MMM-yyyy}"></asp:BoundColumn>
I hope this will help you.
Thanks and Regards,
Chetan Ranpariya
|
|
|
|
|
Hi, can anyone tell where i can donwnload free ASP richtextbox?
Thank
................
|
|
|
|
|
|
|
Hi All..
I have a datagrid holding values in it..I have a button below that datagrid(print button)..If i click the print button the datagrid values should be sent to the printer and the print out must be taken..I have the datagrid in as .aspx page(ASP .NET)..Someone help in this regard with the code..
Regards,
Balaguru
|
|
|
|
|
Balagurunathan S wrote: If i click the print button the datagrid values should be sent to the printer and the print out must be taken
Create one more empty page with this datagrid. Then on the body onload event write window.print. It will open printer dialog
|
|
|
|
|
Plenty of informations is available in the net.
Just google it.
"Printing DataGrid in ASP.NET"
Regards,
Arun Kumar.A
|
|
|
|
|
Have you seen the Article by Russ Quinn in CP.
Print Datagrid in Asp.Net[^]
This article will be very helpful for developing your printing options in a Datagrid in Asp.net
Regards,
Satips.
|
|
|
|
|
Hi
I am a long time powerbuilder developer who has recently started a new job working with asp.net and vb. I am currently using a grid view to display a list of users. I need to be able to delete an unused user from the table. ie one that has had nothing in the referenced table assigned to him. I have set up the auto command button thingy to delete the user in the current row My database works ace with the constraints set up correctly. If I attempt to delete a user that has been referenced elsewhere I get a lovely asp error page saying that it fails the constraint check, and if he hasn't been referenced anywhere he gets deleted. However I want to be able to handle the error so that I get something more meaningful for the user. I have thought about two ways of doing this, and I am a bit stuck on getting either way to work.
The first way I thought of was to place in the rowdeleting event of the gridview a check to say if there exists in the referenced table an instance of the userID then cancel the event using e.cancel(). This would work ace except that I can't for the life of me find the command to reference which row is clicked. Also this means another call to the database which prob isn't so great.
The other way I thought of would be to catch the constraint exception coming from the database. However I can't find where to put this. I mean I assume its a try catch somewhere, but there is no event for the delete being run, its either rowdeleting or rowdeleted. So not sure of the way this should be handled, any help would be most appreciated. I realise this is prob a trivial explanation but there doesn't seem to be a lot of info about it around.
Cheers
Ian Caddick
-- modified at 8:38 Wednesday 25th April, 2007
Ok then think I have managed to solve the problem I have used option one and found out how to return to the row number clicked. It might have seemed like a bit of a trivial option but after much faffing around with dictionary things discovered the datakey object! Why oh why is there not a lot of help around the net on this? This is what I came up with in the end...
<br />
Protected Sub GridView1_RowDeleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GridView1.RowDeleting<br />
<br />
Dim index = Integer.Parse(e.RowIndex)<br />
Dim dk As DataKey<br />
<br />
dk = GridView1.DataKeys.Item(index)<br />
<br />
Dim iOpID = dk.Value<br />
<br />
' Check if the User Can be deleted if he can enable the delete button.<br />
Dim connectionString = sqlSubSystem.ConnectionString<br />
Dim SqlConnection As SqlConnection<br />
SqlConnection = New SqlConnection(connectionString)<br />
Dim Command As SqlCommand<br />
<br />
Dim queryString As String = "SELECT count(subsystemID) FROM dbo.supportcall where [subsystemID] = " & iOpID.ToString()<br />
Command = New SqlCommand(queryString, SqlConnection)<br />
<br />
SqlConnection.Open()<br />
Dim i<br />
i = Command.ExecuteScalar()<br />
SqlConnection.Dispose()<br />
Command.Dispose()<br />
<br />
If i > 0 Then<br />
lblError.Text = "Cannot Delete as Subsystem already in use."<br />
lblError.Visible = True<br />
e.Cancel = True<br />
Else<br />
<br />
End If<br />
<br />
<br />
End Sub
I would still like to know how to do it by catching the constraints exception tho, if anyone can shed any light on that.
Cheers
Cads
|
|
|
|
|
Hi,
I have downloaded the ASP.NET AJAX V1.0 and AJAX Control Tool Kit zip file & Installed the ASP.NET AJAX V1.0 successfully.
How can I Install the AJAX Control Tool Kit? Please help me.
Note: I can't able to view the video in ajax.asp.net website now. (Media player usage was blocked in my office).
Regards,
Jay
|
|
|
|
|
There's no need to install it - just reference the dll in your project.
|
|
|
|
|
Pl. Tell me in steps.
AjaxControlToolkit.zip (runtime binary, 3378K). I have unzipped it. In Binaries folder, I found 3 DLL files.
I have created a new tab in the tool bar. Than, right click, Choose Items --> Browse --> Tools.dll. It gives some error message.
Pls help me.
Regards,
Jay
|
|
|
|
|
Use the AjaxControlToolkit.dll located in SampleWebSite\Bin of the zip file. Seems if this is built in debug mode, so if you need a release version just open the AjaxControlToolkit project (AjaxControlToolkit.csproj) and build it yourself. Then use the dll output.
|
|
|
|
|
Thanks. It works fine.
Regards,
Jay
|
|
|
|