|
Parwej Ahamad wrote: know but Execute reader return the reader object.
Yes but what will happen if exception occurred before ExecuteReader() ? Then dr will not be instantiated
|
|
|
|
|
I agree, But i m post here as per the first post. if you want handle that kind of exception then we need to check Reader is null or not.
Parwej Ahamad
g.parwez@gmail.com
|
|
|
|
|
i think there is no prb wit "dr". 'cos this code works on my local pc. i guess the problem is about server. but what is that:s
|
|
|
|
|
Hello friend.
Do you know ? How to enable-disable web.config section in asp.net by
c#.net or vb.net code ?
I want to disable <httphandler> section by vb.net or C#.net code.
please, help me as soon as possible..
Thanks in advance.
Regards,
Abhi
|
|
|
|
|
Why do you want to do it? Changing web.config on the fly will make your webapp restart.
SG
|
|
|
|
|
Oh ! Yes.
Thanks for you suggestions...
|
|
|
|
|
Hi Everyone,
I need to capture the data from the out parameter of a stored procedure.
str = "{call <Mainframe-SPname>(<Parameters>)}"
Can anyone help me in this regard
-- modified at 3:02 Wednesday 22nd August, 2007
Regards,
Manowj
|
|
|
|
|
I have no idea about IBM DB2.
For SQL, it will be like that.
SqlConnection dbConn = new SqlConnection ("connectionstring");<br />
dbConn.Open ();<br />
SqlCommand cmd = new SqlCommand ();<br />
cmd.Connection = dbConn;<br />
cmd.CommandText = "mystoreProcedureName";<br />
cmd.CommandType = CommandType.StoredProcedure;<br />
SqlParameter param = new SqlParameter();<br />
param.Direction = ParameterDirection.Output;<br />
param.ParameterName = "paramOut";<br />
cmd.Parameters.Add (param); <br />
cmd.ExecuteNonQuery ();<br />
cmd.Dispose ();<br />
dbConn.Close ();
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you.
|
|
|
|
|
I am trying to build a list of items with checkboxes so that the users can remove several items from the list simultaneously. I have the list with the checkboxes displaying correctly. When I select a few items and click the remove button, event does not seem to be able to recognize that the items were selected.
I placed a blank table and CheckBoxList control on my page. I build the table to display the list during the Page_Load event. The list with checkboxes seems to work ok. When the RemoveItems_Click event fires, it cyles through the CheckboxList but it doens't recognized the Selected attribute so that I can remove the items.
Here are the relevant code snippets. Thanks for any feedback!
<asp:table id="ViewTable" runat="server">
<asp:checkboxlist id="RemoveItemsCheckBoxList" runat="server"
="" visible="False">
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
GetItemLists(RemoveItemsCheckBoxList);
}
}
public static void GetItemLists(CheckBoxList checkBoxList)
{
// Connect and fetch data
while (sqlDataReader.Read())
{
// build the ViewTable
// now create the checkbox and add it to the table
CheckBox checkBox = new CheckBox();
checkBox.ID = "RemoveCheckbox" + sqlDataReader["Id"].ToString();
checkBoxList.Items.Add(checkBox.ID.ToString());
cell = new TableCell();
cell.Controls.Add(checkBox);
row.Cells.Add(cell);
}
// clean up
}
protected void RemoveItemsButton_Click(object sender, EventArgs e)
{
foreach (ListItem listItem in RemoveItemsCheckBoxList.Items)
{
if (listItem.Selected == true)
{
// Remove the Item
...
}
}
|
|
|
|
|
I think you need to set AutoPost to true.
CheckBoxList1.AutoPostBack = true;
Hope it helps.
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you.
|
|
|
|
|
Hi!
I need some assistance.
I am using ASP.NET 2.0 Login Controls for my site and Roles are enabled. My problem is that I have a form with a dropdownlist. When a person signs on and he is in Role1 than all Role1 users must be displayed in the dropdown. If Role2 signs on then everyone from Role2 must be displayed.
Much appreciated!
Illegal Operation
Making Computer Software Talk
|
|
|
|
|
What is the life cycle of asp.net page
|
|
|
|
|
|
One of the most confusing things in ASP.NET
picture (big)[^]
[ My Blog] "Visual studio desperately needs some performance improvements. It is sometimes almost as slow as eclipse." - Rüdiger Klaehn "Real men use mspaint for writing code and notepad for designing graphics." - Anna-Jayne Metcalfe
|
|
|
|
|
in addition to michael's answers..
http://www.15seconds.com/Issue/020102.htm
http://www.c-sharpcorner.com/UploadFile/Santhi.M/ASP.NETLifeCycle11282005043446AM/ASP.NETLifeCycle.aspx
suggestion:google to these kind of topics
|
|
|
|
|
Hello friends,
I have to start one new project,
Automatic installation of mysql db in the local machine, the function is when the exe is run.The programm should automatically detect if My sql db is alreadyy installed, if not installed then the Mysql setup file will run automatically
Please let me know how to work on this project, anybody have sample code please give and help me...
Thanks
Praveen Kumar.R
|
|
|
|
|
In your program start ODBC connection to my sql server. If MySQL service is not running, it will throw exception. Catch it and initialize MySQL setup file. Are you trying to do this on ASP.NET ?
|
|
|
|
|
hi, i am using a library to allow users to upload files through the application, it was working well but when my host provider changed the domain address, i also changed my code to fit the new one but it works with some and others it gives me an error of
(Cannot find part of the path......) or (cannot find file windows/system32/...)
please help me
thanks
abdelhameed81
|
|
|
|
|
Are you using "server.mappath" to specify your directory? Without seeing your code, the best I can do is provide an example of a solution I'm using that uploads successfully. In this sample, I upload the file into an "Uploads" folder on my server:
.aspx file:
-----------------------------------------------------------
<TR>
<TD class=td7_c align=right></TD>
<TD align=left><asp:FileUpload ID="fu_File1" runat="server"/></TD>
</TR>
<TR>
<td></td>
<td align="right">
<asp:Button ID="btnUpload" runat="server" OnClick="btnUpload_Click" Text="Upload"></asp:Button>
</td>
</TR>
-----------------------------------------------------------
.cs codebehind file:
-----------------------------------------------------------
#region Click Events
protected void btnUpload_Click(object sender, EventArgs e)
{
string targetDirectory;
if (fu_File1.HasFile)
{
targetDirectory = Server.MapPath(@"Uploads/" + fu_File1.FileName);
fu_File1.SaveAs(targetDirectory);
string dir = fu_File1.PostedFile.FileName;
Response.Write(dir);
}
}
#endregion
--------------------------------------------------------------
Hope that helps.
-Goalie35
|
|
|
|
|
Hi All,
I want to validate textbox in gridview for phone number through Javascript only. How can do this
Thanks!
|
|
|
|
|
swami samarth wrote: I want to validate textbox in gridview for phone number through Javascript only. How can do this
You can add a Custom Validator which points to that textbox in the template column of GridView. then, call the javascript function from GridView.
DEMO
The following code is for Server-side ~
using System;<br />
using System.Data;<br />
using System.Configuration;<br />
using System.Collections;<br />
using System.Web;<br />
using System.Web.Security;<br />
using System.Web.UI;<br />
using System.Web.UI.WebControls;<br />
using System.Web.UI.WebControls.WebParts;<br />
using System.Web.UI.HtmlControls;<br />
using System.Collections.Generic;<br />
<br />
public partial class Default2 :System.Web.UI.Page {<br />
protected void Page_Load(object sender, EventArgs e)<br />
{ <br />
System.Collections.Generic.List<string> s = new List<string>();<br />
s.Add("Ruby");<br />
s.Add("Diamond");<br />
s.Add("Gold");<br />
GridView1.DataSource = s;<br />
GridView1.DataBind ();<br />
}<br />
<br />
}<br />
I will post the HTML code in next thread. (otherwise, i will lose the formatting here.)
Note: isValidPhoneNumber is a javascript function to check phone number. I set this code ClientValidationFunction="isValidPhoneNumber" ControlToValidate="TextBox1" in custom validator which is put in the template column of GridView. Textbox1 is a textbox which is put in the template column of GridView.
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you.
|
|
|
|
|
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<meta http-equiv="cache-control" content="no-cache">
</head>
<body>
<script language="javascript" type="text/javascript">
function isValidPhoneNumber(sender, args){
if(args.Value == "something")
args.IsValid = true;
else
args.IsValid = false;
}
</script>
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView1" runat="server" Width="249px">
<Columns>
<asp:TemplateField HeaderText="1">
<ItemTemplate>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:CustomValidator ID="CustomValidator1" runat="server" ClientValidationFunction="isValidPhoneNumber"
ControlToValidate="TextBox1" ErrorMessage="CustomValidator"></asp:CustomValidator>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="2">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="3"></asp:TemplateField>
</Columns>
</asp:GridView>
<asp:ValidationSummary ID="ValidationSummary1" runat="server" />
<asp:Button ID="Button1" runat="server" Text="Button" /></div>
</form>
</body>
</html>
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you.
|
|
|
|
|
Hi,
I am using the TabContainer, in which I have 6 tabpanels. On page load I want to visible only first 4 Tabpanel. and remaining two should be invisible.
How can I do this at runtime.
Thanks!
|
|
|
|
|
It will be something like this:
In the PageLoad put this,
IF(Page.IsPostback)
{
Panel1.visible = "True"
Panel2.visible = "True"
Panel3.visible = "True"
Panel4.visible = "True"
Panel5.visible = "False"
Panel6.visible = "False"
}
Else
{
}
You can also use the Select Case for this.
Hope it helps!
Illegal Operation
Making Computer Software Talk
|
|
|
|
|
how can i create a .pdf file. I have a string with a html code. I need to make a .pdf file using that code.How can i make without using third party .dll. Is it possible to make by saving as .pdf, but i try and i didt got.
Thks
|
|
|
|