|
I m developing a module in which i m entering data to temporary table.and Secondly shows that data in gridview and updating that data and save that data in a table.
Till showing that data in Gridview works well.
But when i want to Update that data,Error comes for some fields.
I m using asp.net2.0
My code is :
Protected Sub Add_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Add.Click
imagesupload()
addtemp()
End Sub
Sub imagesupload()
'Dim sp As String
'sp = Server.MapPath("images")
'Dim fp As String
'fp = Fileupload.PostedFile.FileName
'Dim fn As String
'fn = Guid.NewGuid.ToString() + fp.Substring(fp.LastIndexOf("."))
'If sp.EndsWith("\\") = False Then
' sp += "\\"
'End If
'sp += fn
'Fileupload.PostedFile.SaveAs(sp)
'Response.Write("fileupload")
Dim sp As String
sp = Server.MapPath("images")
Dim fp As String
fp = Fileupload.PostedFile.FileName
If fp = "" Then
Response.Write("please upload files")
Exit Sub
End If
Dim fn As String
fn = Guid.NewGuid.ToString() + fp.Substring(fp.LastIndexOf("."))
If sp.EndsWith("\\") = False Then
sp += "\\"
End If
sp += fn
Fileupload.PostedFile.SaveAs(sp)
Response.Write("fileupload")
End Sub
Sub Companytype()
Dim ds As New DataSet
Dim listitem As New ListItem
DdtypeCmp.DataTextField = "cmptypnam"
DdtypeCmp.DataValueField = "cmptypcod"
DdtypeCmp.DataSource = obj.GetCompanytype
DdtypeCmp.DataBind()
listitem.Text = "Select"
listitem.Value = -1
DdtypeCmp.Items.Insert(0, listitem)
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
listitem.Text = "Select"
listitem.Value = -1
DDbchcnt.Items.Insert(0, listitem)
listitem1.Text = "Select"
listitem1.Value = -1
DDbchSta.Items.Insert(0, listitem1)
listitem2.Text = "Select"
listitem2.Value = -1
ddbchcty.Items.Insert(0, listitem2)
Companytype()
Dim tb As New DataTable("Brcdet")
'Dim col As New DataColumn
'col.ColumnName = "Name"
'col.DataType = Type.GetType("System.String")
''col.Unique = True
'col.ReadOnly = False
'tb.Columns.Add(col)
Dim col As New DataColumn
col.ColumnName = "CompanyCode"
col.DataType = Type.GetType("System.Int32")
col.AutoIncrement = True
col.ReadOnly = True
col.AutoIncrementSeed = 100
col.AutoIncrementStep = 1
tb.Columns.Add(col)
Dim col1 As New DataColumn
col1.ColumnName = "Company Name"
col1.DataType = Type.GetType("System.String")
'col.Unique = True
col1.ReadOnly = False
tb.Columns.Add(col1)
'Dim col1 As New DataColumn
'col1.ColumnName = "CompanyCode"
'col1.DataType = Type.GetType("System.Int32")
'col1.AutoIncrement = True
'col1.ReadOnly = True
'col1.AutoIncrementSeed = 100
'col1.AutoIncrementStep = 1
'tb.Columns.Add(col1)
Dim col2 As New DataColumn
col2.ColumnName = "Company profile"
col2.DataType = Type.GetType("System.String")
col2.ReadOnly = True
tb.Columns.Add(col2)
'tb.Columns.Add(New DataColumn("Rate", Type.GetType("System.int32")))
Dim col3 As New DataColumn
col3.ColumnName = "Company Image"
col3.DataType = Type.GetType("System.String")
col3.ReadOnly = True
tb.Columns.Add(col3)
Dim col4 As New DataColumn
col4.ColumnName = "Company Type"
col4.DataType = Type.GetType("System.String")
tb.Columns.Add(col4)
Dim col5 As New DataColumn
col5.ColumnName = "Company URL"
col5.DataType = Type.GetType("System.String")
col5.ReadOnly = True
tb.Columns.Add(col5)
Dim col6 As New DataColumn
col6.ColumnName = "BranchName"
col6.DataType = Type.GetType("System.String")
col6.ReadOnly = True
tb.Columns.Add(col6)
Dim col7 As New DataColumn
col7.ColumnName = "BranchAddress"
col7.DataType = Type.GetType("System.String")
col7.ReadOnly = False
tb.Columns.Add(col7)
Dim col8 As New DataColumn
col8.ColumnName = "BranchPhone"
col8.DataType = Type.GetType("System.Int32")
tb.Columns.Add(col8)
Dim col9 As New DataColumn
col9.ColumnName = "BranchEmail"
col9.DataType = Type.GetType("System.String")
tb.Columns.Add(col9)
Dim col10 As New DataColumn
col10.ColumnName = "Branchpin"
col10.DataType = Type.GetType("System.Int32")
tb.Columns.Add(col10)
Dim col11 As New DataColumn
col11.ColumnName = "Branchfax"
col11.DataType = Type.GetType("System.Int32")
tb.Columns.Add(col11)
Dim col12 As New DataColumn
col12.ColumnName = "BranchCountry"
col12.DataType = Type.GetType("System.String")
tb.Columns.Add(col12)
Dim col13 As New DataColumn
col13.ColumnName = "BranchState"
col13.DataType = Type.GetType("System.String")
tb.Columns.Add(col13)
Dim col14 As New DataColumn
col14.ColumnName = "BranchCity"
col14.DataType = Type.GetType("System.String")
tb.Columns.Add(col14)
Dim s(0) As DataColumn
s(0) = tb.Columns("CompanyCode")
tb.PrimaryKey = s
ViewState("abc") = tb
cmpname = txtname.Text
End If
Add.Attributes.Add("OnClick", "return Validate();")
'TxtBchadd.Attributes.Add("OnClick", "return bchadd();")
End Sub
Sub addtemp()
ListItem.Text = "Select"
ListItem.Value = -1
DDbchcnt.Items.Insert(0, ListItem)
listitem1.Text = "Select"
listitem1.Value = -1
DDbchSta.Items.Insert(0, listitem1)
listitem2.Text = "Select"
listitem2.Value = -1
ddbchcty.Items.Insert(0, listitem2)
Dim tb As New DataTable
tb = ViewState("abc")
Dim r As DataRow
r = tb.NewRow()
r("Company Name") = txtname.Text
cmpname = txtname.Text
r("Company profile") = txtprofile.Text
cmpprofile = txtprofile.Text
r("Company Image") = Fileupload.PostedFile.FileName
r("Company Type") = DdtypeCmp.SelectedValue
cmptype = DdtypeCmp.SelectedValue
r("Company URL") = txturl.Text
cmpurl = txturl.Text
r("BranchName") = TxtBchNam.Text
branchname = TxtBchNam.Text
r("BranchAddress") = TxtBchadd.Text
bchadd = TxtBchadd.Text
r("branchphone") = Convert.ToInt32(txtbchphn.Text)
bchphone = txtbchphn.Text
r("BranchEmail") = txtbcheml.Text
bchemail = txtbcheml.Text
r("Branchpin") = Convert.ToInt32(txtbchpin.Text)
bchpin = txtbchpin.Text
r("Branchfax") = Convert.ToInt32(txtbchfax.Text)
bchfax = txtbchfax.Text
r("BranchCountry") = DDbchcnt.SelectedItem.Text
bchcnt = DDbchcnt.SelectedValue
r("BranchState") = DDbchSta.SelectedItem.Text
bchstate = DDbchSta.Text
r("BranchCity") = ddbchcty.SelectedItem.Text
bchcity = ddbchcty.Text
tb.Rows.Add(r)
GrdTmp.DataSource = tb
GrdTmp.DataBind()
End Sub
Protected Sub GrdTmp_RowCancelingEdit(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCancelEditEventArgs) Handles GrdTmp.RowCancelingEdit
GrdTmp.EditIndex = -1
End Sub
Protected Sub GrdTmp_RowDeleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GrdTmp.RowDeleting
Dim tb As New DataTable
tb = ViewState("abc")
tb.Rows.RemoveAt(e.RowIndex)
GrdTmp.DataSource = tb
GrdTmp.DataBind()
End Sub
Protected Sub GrdTmp_RowEditing(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles GrdTmp.RowEditing
GrdTmp.EditIndex = e.NewEditIndex
Dim tb As New DataTable
tb = ViewState("abc")
GrdTmp.DataSource = tb
GrdTmp.DataBind()
End Sub
Protected Sub GrdTmp_RowUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles GrdTmp.RowUpdating
Dim tb As New DataTable
tb = ViewState("abc")
'tb.Rows(e.RowIndex)(0) = CType(GrdTmp.Rows(e.RowIndex).Cells(1).Controls(0), TextBox).Text
tb.Rows(e.RowIndex).Item("BranchAddress") = CType(GrdTmp.Rows(e.RowIndex).Cells("BranchAddress").Controls(0), TextBox).Text
tb.Rows(e.RowIndex).Item("BranchPhone") = Convert.ToInt32(CType(GrdTmp.Rows(e.RowIndex).Cells("BranchPhone").Controls(0), TextBox).Text)
tb.Rows(e.RowIndex).Item("BranchEmail") = CType(GrdTmp.Rows(e.RowIndex).Cells("BranchEmail").Controls(0), TextBox).Text
tb.Rows(e.RowIndex).Item("Branchfax") = CType(GrdTmp.Rows(e.RowIndex).Cells(13).Controls("Branchfax"), TextBox).Text
tb.Rows(e.RowIndex).Item("BranchCity") = CType(GrdTmp.Rows(e.RowIndex).Cells("BranchCity").Controls(0), TextBox).Text
GrdTmp.EditIndex = -1
GrdTmp.DataSource = tb
GrdTmp.DataBind()
End Sub
Any body solve this problem.
Its urgent.
Thanks in advance.
kartik
|
|
|
|
|
I m having class file (CSharp) to Display Numbers in Words. How to access this file in WebForm.
Thanks in advance.
|
|
|
|
|
Please elaborate bit it bit more
Regards,
Akhilesh Yadav
|
|
|
|
|
Place the class file in the project, then access it as you would any other class.
|
|
|
|
|
Hi,
I am new to .Net2.0. In my Asp.Net application using C# I used a dropdownlist for which lots of data is being binded to. Inorder to make my application user friendly i need a Combo box, but I couldn't find it in the tool box. I searched for it over the internet, but of no use. Please help me.
Thanking You in Advance.
-- modified at 6:07 Thursday 26th October, 2006
Srinivasarao Lalam
|
|
|
|
|
hi jenious
this is ajay
i m facing a problem while connecting asp.net page to crystal report.
i have the following code.
ObjsqlAdapter = New SqlDataAdapter(Objsqlcommand)
ObjDataset = New DataSet
ObjsqlAdapter.Fill(ObjDataset)
Dim rptDetail As New crptDetailReport
rptDetail.Refresh()
rptDetail.SetDataSource(ObjDataset.Tables(0))
CrystalReportViewer1.ReportSource = rptDetail
CrystalReportViewer1.DataBind()
here crptdetailreport is my crystalreport.
objdataset is my dataset.
problem is that i m not gettin anything on my report.
although dataset is accurate
nd i hav also added the database field on my report.
wht could be the reason.
i m very much eager for the solution
thanks in advance.
|
|
|
|
|
Hi
I have a detailsview which is loaded from a datagrid. What I want is that when you edit the record, i want it to not just edit that record but actually insert a new updated record with the new details and put a close on the previous.
I have a stored procedure which does this (as the application was originally done in .net1 and we wanted to see how we would go about doing it in .net2) But the way the details view works it wont allow us to use the storedprocedure on the edit/update section. So ive tried to do it by adding my own submit button to the update field by creating it to a template field. But now we cant find anyway of from this button writing the code to call the stored procedure and insert from the sqldatasource.
Please can anyone help with this?
Thanks
Adam
|
|
|
|
|
i want when i double click on datagrid i can go to the other form and send a vaue to that form i do this work but its not right
how can u help me?
e.Row.Attributes.Add("OnDblClick","javascript:document.url='Frm_Skin.aspx?'"+e.Row.Cells[1].Text);
|
|
|
|
|
http://authors.aspalliance.com/das/datagriddblclick.aspx
Thomas
|
|
|
|
|
i understand that but i cant create a link for go to the other form with double click
how u can help me
|
|
|
|
|
Is this doable?
We're looking to develop an application that allows you to enter a domain (www.thewebsitename.com) and have the application return a list of all pages associated with that domain. (www.thewebsitename.com/allthesepages).
sanjeev
|
|
|
|
|
sharma sanjeev wrote: Is this doable?
Yes, it is doable.
|
|
|
|
|
thanks for your reply colin. please help me out and suggest in what way i can do this? have you ever made or seen such application. will be thankful if i can see that.
thanks in advance for your next reply
sanjeev sharma
Software engineer
Graycell technologies exports
chandigarh
india
www.graycelltech.com
|
|
|
|
|
sharma sanjeev wrote: please help me out and suggest in what way i can do this?
You crawl the sites for links. You follow the links building up your database as you go. (In pretty much the same way as Google does)
Once you have your database looking it up should be fairly simple.
|
|
|
|
|
Take a look at my reply on the C# forum.
Arthur Dent - "That would explain it. All my life I've had this strange feeling that there's something big and sinister going on in the world."
Slartibartfast - "No. That's perfectly normal paranoia. Everybody in the universe gets that."
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hi,
In my site on IIS 5.1 with Asp.net 1.1 ,
I have a problem with a virtual dirtectory that points to a share on another computer.In IIS I put in the 'connect as' the right user and pass that has access to that share.Now when I test my code It works without a problem but from a remote client I get ' access to the path '' is denied'.
But some pieces work from remote, for example if I use a Response.write("win.open(http://fullpath..)") then i can open the files;
but when I want to get all the files in a folder with Directory.GetDirectories(path) I get the access denied error.
I can't impersonate the user that has access to the fileshare, cause I need to do rolebased checks in COM+.
thanks for any help..
|
|
|
|
|
In sqlserver Database,datatype is smalldate/time
and i tried following code
Dim dtmDate As Date
dtmDate = Date.Parse(TxtDat.Text)
Response.Write("dtmdate")
But it is giving String is not a valid datetype.How to format it examctle to isert into database.
I need to isert only date not with the time.
Help me out.please
kissy
|
|
|
|
|
Try this.
Date.Parse(TxtDat.Text).ToString("dd/MM/yyyy")
Thomas
|
|
|
|
|
It is giving an errot that String was not recognised as valid Date.
Give me solution,i Have used as below
Dim dtmDate As DateTime
dtmDate = Date.Parse(TxtDat.Text).ToString("mm-dd-yyyy")
Response.Write("dtmdate")
Here i am taking date from Calender.
How to solve this,Thanks for ur answer
kissy
|
|
|
|
|
Your date format string is wrong. Use capital ‘M’ in the place of month. Like this "MM-dd-yyyy"
Thomas
|
|
|
|
|
But eventhough i changed it is givig the same error.Where exactle i have to change the format,or else give me anothe idea
kissy
|
|
|
|
|
what are you passing in your text box??
I mean what exactly you want to do?
|
|
|
|
|
You pass value in text box in mm/dd/yyyy format and you can display that value by following code
stdate = DateTime.Parse(TextBox1.Text)
Response.Write(stdate.ToString("dd MMM yyyy"))
so if you pass 10/26/2006
it will display 26 Oct 2006
you can change format of date but you have to pass date in textbox in mm/dd/yyy format
Try it
|
|
|
|
|
Dim stdate As DateTime = DateTime.Parse(TxtDat.Text)
Dim strdate As DateTime = stdate.ToString("dd MM yyyy")
and i am trying to isert this strdate valued into my smalldatetime datatype value in database.Then it is giving error that cast from 26 10 2006 to Date is not valid.Waht exactle i have to insert into my database for insertion of Date column.Like 26/10/2006
kissy
|
|
|
|
|
Dim strdate As DateTime = stdate.ToString("dd MM yyyy")
this will never work kissy. as you are converting string into datetime
so dont do that. instead you pass value when you are inserting it into database. and dont worry abot smalldatetime datatype it will take any value of date. so try to insert it as it is. and then let me know the changes
Try it
|
|
|
|