|
Your controls need to be added before the page load event, otherwise they don't exist when the viewstate tree is recreated, so the values are lost.
Christian Graus - Microsoft MVP - C++
"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 )
|
|
|
|
|
well done...I tried Page_Init event..it creates Label control without causing any exception..but when I added my textbox type control to page it throws an exception that "the TextBox type control must be in form runat=server tag"..
please any suggestion?
hi all frieds!!
piece in home,piece in world!
|
|
|
|
|
Hi,
I would like to know how I can add a headerRow to a gridview, before I show it on the page. I will never know how many columns there will be(get amount of columns from another source), so I have to loop through an array each time, check how many columms there are, and then create a column(with text name) for each of the array items.
How will I add code to the following code, to add a header row?
<br />
'dtInvoice = datatable 'gdvInvoice = gridview<br />
gdvInvoice.DataSource = dtInvoice<br />
gdvInvoice.EmptyDataText = "No Data to Display"<br />
gdvInvoice.PagerSettings.Position = PagerPosition.Top<br />
gdvInvoice.AllowSorting = True<br />
<br />
Dim keyArray() As String = {ViewState("AppPrimaryKey")}<br />
gdvInvoice.DataKeyNames = keyArray<br />
<br />
gdvInvoice.DataBind()<br />
gdvInvoice.Visible = True<br />
|
|
|
|
|
i want to retrieve primary key of parent table and then send this key to child table,as they have one-one relationship
i've written code
string id = "SELECT MAX(c_id) FROM call_history";
SqlCommand com1 = new SqlCommand(id, conn);
SqlDataReader dr = com1.ExecuteReader();
if (dr.Read())
{
int i = Convert.ToInt32(dr.GetValue(1));
}
strQuery1 = "INSERT INTO call_log(c_id,c_add)VALUES("+ i +",'"+textBox2.Text +"')";
SqlCommand commm = new SqlCommand(strQuery1, conn);
commm.ExecuteNonQuery();
but it is goiving an error on insert atement that
"Use of unassigned local variable 'i' "
$h@ma!|@
|
|
|
|
|
$h@ma!|@ wrote: int i = Convert.ToInt32(dr.GetValue(1));
Your variable is defined inside your brackets, but you try to use it after it's dropped out of scope. Move your } to the bottom of this code block and it will work.
I'd recommend reading a book on C#, if you're unaware of hte scoping rules.
$h@ma!|@ wrote: strQuery1 = "INSERT INTO call_log(c_id,c_add)VALUES("+ i +",'"+textBox2.Text +"')";
I recommend you do some reading on SQL injection attacks. This sort of code allows people to run any SQL they like on your database.
$h@ma!|@ wrote: $h@ma!|@
Does that translate to shemale ?
Christian Graus - Microsoft MVP - C++
"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 )
|
|
|
|
|
this time i defined i globaly but still having the same problem...is there any problem in the insert statement??
have i written the sql command rite??/
$h@ma!|@
|
|
|
|
|
hi,
i am using a report viewer control in my application.i have many records with the same value in name column.i have to group the name n display it once in the report with its other details
ex:
name job
zari swengineer
swtester
businessanalyst
zari
|
|
|
|
|
Are you making use of the Crystal Report Wizard to create your report or are you creating your report in code? This you have to do in the report itself, since the viewer only do what it says: View.
There is 2 solutions.
You can either create a grouping for that field
OR
You can sort that field so that all that names are together then you format that field to tell him to suppress duplicates. That way you will see the name once.
|
|
|
|
|
Hi,
I'm using MS Access 2003 database with c#.net 2003. Now I've a comobo, in which department name are shown and onchangeindex i use to get department code, show i textbox. Now the problem is this when i add department no 11 in the database, my comobox stop working and i got javascript error:
Error:Invaild Syntax in statusbar.
Kindly help where i made a mistake ( In web code or database) I use normal database settings.
Thanks
|Muhamad Waqas Butt|
waqasb4all@yahoo.com
www.sktech.freewebspace.com
|
|
|
|
|
Please post your code or run your application with the Break point and try to locate in which line the error shows.
We are not magic man without seeing the code how can we tell where the error is.
Regards,
Satips.
|
|
|
|
|
Here is a code:
try
{
string cmdstr="SELECT * FROM tablename where dp_head='"+ dpdhead.SelectedValue +"'";
con=new OleDbConnection(cons);
cmd=new OleDbCommand(cmdstr,con);
con.Open();
OleDbDataReader dr = cmd.ExecuteReader();
bool chkrec = dr.Read();
if(chkrec == true)
{
string dasv = dr.GetInt32(0).ToString();
txtacno.Text = dasv;
}
//
Output
'/LM/w3svc/1/root/expdemo-5-128280938191702288': Loaded 'c:\windows\microsoft.net\framework\v1.1.4322\temporary asp.net files\expdemo\280c9982\bd477ac7\gottf48d.dll', Symbols loaded.
// Now
|Muhamad Waqas Butt|
waqasb4all@yahoo.com
www.sktech.freewebspace.com
|
|
|
|
|
You may be better off by using a Parameter List for your OleDBCommand Object.
replace your appropriate lines:
string cmdstr = "SELECT * FROM Tablename where field = @fieldvalue;";
cmd = new OleDBCommand(cmdstr,con);
cmd.Parameters.AddWithParameter("@fieldvalue",dpdhead.SelectedValue);
Parameter Lists help organization And is another obstacle for Hackers.
Also look to this:
string dasv = dr[0].ToString();
|
|
|
|
|
Respected Gurus
I m using following code to import data from an excel file..
It works fine except one problem that
whenever i m trying to delete the file which i have saved on the server by using
file.delete(strfilename)
i left with the error "you do not have permission"
I think i have not closed the excel file.
how can i close it programmatically so that i can delete it also.
Dim strfilename As String
' Check the first open file dialog for a value
If Not (Me.File1.PostedFile Is Nothing) Then
' Get a reference to PostedFile object
Dim attFile As HttpPostedFile = File1.PostedFile
' Get size of the file
Dim attachFileLength As Integer = attFile.ContentLength
'Make sure the size of the file is > 0
If attachFileLength > 0 Then
' Get the file name
strfilename = Path.GetFileName(File1.PostedFile.FileName)
'Preceed the file name with "attachments/" so
'the file is saved to our Project's attachments Folder
strfilename = "Uploads/" + strfilename
'Save the file on the server
File1.PostedFile.SaveAs(Server.MapPath(strfilename))
End If
End If
Dim strConnectionString As String = String.Empty
'----------------------------------------------------------
'strConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Driver=Microsoft Text Driver (*.txt;*.csv);Data Source=" + Server.MapPath(strfilename) + ";Extensions=asc,csv,tab,txt;Persist Security Info=False"
'----------------------------------------------------------
strConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath(strfilename) + ";Extended Properties=""Excel 8.0;HDR=Yes;IMEX=1"""
Dim cnCSV As New OleDbConnection(strConnectionString)
cnCSV.Open()
Dim cmdSelect As New OleDbCommand("SELECT * FROM [sheet1$]", cnCSV)
cmdSelect.CommandType = CommandType.Text
Dim daCSV As New OleDbDataAdapter
daCSV.SelectCommand = cmdSelect
Dim ds As New DataSet
daCSV.Fill(ds)
after using the dataset.
at last i am trying to delete the file.
which give me the error.
Please Help.
|
|
|
|
|
please check out your system configuration. have your system has permission to delete any file. could be possible this.
Devjit
|
|
|
|
|
Your web site runs under an app pool. That app pool has an identity. That user that the app pool is running as needs to be able to delete files in the correct directory. Often it makes sense to create a new app pool for each new web application. Then you can create a network user for that specific application and give that user the correct rights.
Ben
|
|
|
|
|
Thanks sir
resolve it
was a permission issue.
given the rights and now working smoothly.
|
|
|
|
|
I have developed a two way Client Server Chat Application using .Net Remoting. where Server Application have real IP but Client Application Donot have real IP. but my application is working in LAN Environment But CallBack and deleget is not working in real world scenario.
Pavan Pareta
|
|
|
|
|
can i personally talk to u.I need to talk to u about chat programatically.
my yahoo mail id is soniagupta1@yahoo.co.in.
i am waiting at yahoo messenger
|
|
|
|
|
Hi Sonia Gupta,
here is not allowed any kind of messenger.
Pavan Pareta
|
|
|
|
|
how to give runtime file name to file control
i have created file control at run time
FileUpload up = new FileUpload();
but i want to give its path in code view how will i give it
|
|
|
|
|
if you wanna see the absoulte path you could use : fu.PostedFile.FileName;
or else you can use to get only file name you uploaded using that code : fu.FileName;
Hope it helps..'
|
|
|
|
|
i want to copy file in web application i am using
File.Copy("c:/somefile.txt","http://makarand/Wow/Data/Origs/someotherfile.txt"
);
i am getting this error
URI formats are not supported
pls tell me what is an issue does and what should i do to copy the file
|
|
|
|
|
man you gotta use Server.MapPath to point a place in your server.
-- modified at 8:13 Thursday 5th July, 2007
|
|
|
|
|
i have did that. it works fine when i am working on my machine but it won't work wen i am using remote machine.
|
|
|
|
|
i was trying to write the asp code in asp.net 2.0
the following code.
<% @Language=VBScript%>
<% Option Explicit %>
<%
set objRS=Server.CreateObject("ADODB.Recordset")
objRS.Open objConn
%>
but the set and get keywords ae not supported .
|
|
|
|