ddl selected index change

I am makin a .net web application..on page.aspx i ve 2 ddl of states and cities.When i select option in ddlstate i get corresponding cities , but when i again select a state , i get cities corresponding to present as well as previous state that i selected earlier.How should i solve this
(i ve used database table to access cities corresponding to states using arraylist)
code behind for selected index changed---

void ddlstate_selectedindexchanged(object sender,event args e)
class1 c1=new class1(); //class1 contains method fillcity that has returns cities in arraylist

arraylist al=new arraylist();

al=null//initialising arraylist

al=c2.fillcity(ddl.selecteditem.text);//fillcity has input parameter as state which has tp be selected

for(int i=0;i

Posted On: Tuesday 1st of January 2013 09:33:09 PM Total Views:  253
View Complete with Replies

Related Messages:

Close a popup window   (252 Views)
:confused:I have a hyperlink in a template column of my datagrid which opens a pop-up page to enter data. I have the following code in this page's load event to close the windowMe.Button1.Attributes.Add("OnClick", "window.close()")However, it closes the popup page and the main page. How can I just close the pop-up page.TIA
View State and User Controls   (170 Views)
I was going to create a Server Side Control (am unbound grid control) in ASP .NET and I got a problem to hanlde view state of the control. Can anyone tell me that how can I store the view state of an object in ASP .NET I was writing the code something like this in User Control. Public Class MyGridControl Inherits System.web................... ''''' Override the CreateChild method. Dim mTable as new Table() Dim mRow as new TableRow() Dim tempRows, tempCols as integer, For tempRows = 1 to 5 mRow = New TableRow() For tempCols = 1 to 5 Dim mTD as new TableCless() mTD.Controls.Add (New TextBox()) mRow.Cells.Add (mTD) Next mTable.Rows.Add (mTR) Next MyBase.Controls.Add (mTable) 'End of CreateChildControls And then used this control in my ASP Page. It created the Grid like thing which contains 5 rows and 5 cols. Now I wrote something in the textboxes of the grids and hit Button which caused the Post Back Event. Now when the form came back, the textboxes were blank. I know, that I am creating the Grid at CreateChild methods and each time, it is creating new textboxes so the textboxes are blank. But the same is the question. How can I persists the view state of dynamically created elemnts. I hope that the question is clear now and you people will give me some solution for this.
web.config problem   (187 Views)
I am having trouble with my web.config file recognizing the tag. I get the error Unrecognized configuration section 'connectionStrings'. The exact same web.config file works in other projects. Is there something I have to do to make it recognize this tag
Session end while getting an exception   (209 Views)
I have a problem. I have designed a shopping app where I use the session state to store some information. I ahve noticed that every time my code generates an exception, the session_end event fires. Why is it like that, and what can I do to avoid it This is really annoying since all I want to do is to display a javascript messagebox and allow the user to continue shopping. As it works now, i must redirect the user to the login page every time an exception is caught. /Henrik
Reset webform without using HTML reset button???   (190 Views)
On my webform I am currently using the HTML Reset button to reset the form. The problem is that when the form is viewed by someone to approve I would like to hide the button along with some other options to be available only on data entry. Is there another way i can reset the form, possibly in vbscript. I tried doing it in javascript but the validateRequiredFields that I have on the form fires stopping the reset. Anyone have any ideas
Run ItemCommand automatically   (251 Views)
I have two text boxes in the Item Template of my datagrid. if the user double clicks in them today's date isautomatically is entered, or they can actually type inthe date they want in the text boxes. They then have to click a button which saves these dates. The code for this is in the Datagrid's Itemcommand. works fine. My user wants the dates to save automatically without clicking the save button. Is there a way to do this TIA
Output to Excel   (198 Views)
Using this code: Response.ContentType = "application/ms-excel" Response.AppendHeader("Content-Disposition", "attachment; filename=worksheet.xls") Response.Flush() ...I'm getting an "unable to read file" error when I try to open the file in Excel. It seems to be saving it, but I'm not convinced in a readable format. Does anyone have any suggestions regarding this or other methods of sending an aspx page to Excel from the web form
Format Phone Number in GridView   (197 Views)
I've been trying to figure out how to format a phone number column in a grid view I found a relevant Post psycho coder had a great regex function to actually format the number ... However, I have some issues figuring out to implement this, i'm very new to this level ASP programing, do more C# windows based stuff ... I'm using a LINQ Data Source to a generated GridView, do I have to write the code Query data then loop through and generate the grid view to utilize this, or is there a more straight forward approach Any Input is greatly appreciated ...
How can we write code to Add textbox Control In DataGrid   (212 Views)
Plz, GIve me code.
How to display an XP shutdown screen fade-off effect in   (284 Views)
,I am wondering who ever did this in web application:Pop up a dialog window, all the rest of the screen will be disabled, just like when you shut down your machine, you can only click on the popup window.
inserting all record in a dataset to a database table   (272 Views)
good day...problem: at the the click of a button (btnSubmit), i want all the records displayed in a datagrid (connected to a dataset) to be inserted in a table in a SQL database.I know I can loop through each record, and insert this records in a table one by one. The problem with this is that it will take significantly much time (i presume) for these records to be added to the table via internet. So, is there anyway I can insert these records with a single command, or at least without having to loopany inforamtion or advice wil be highly appreciatedwouter
How to make it   (293 Views)
Hi , I am working on web-based application and i can make my custom control named mygrid.ascx, now i want to make this custom control's dll that i don't want to use my control on another page or machine again and again. I can just add my control's dll into tool-box window, i'm just darg it and used it properties. It's very urgent anyone help me plz variable data type   (361 Views)
I have a database table in which one field is defined as text data type. At the page, what data type variable should I use to get the value from a form element Should it be string type and can it hold 10,000 characters, which I can insert into this database table column, which is defined as text data typ
DataGrid and TextBox Probelm and PostBack   (222 Views)
Hi ,I have following 2 Problems. I wanted to paste my code but due to size limitation from Vbcity, I have to attach that code. The file name is BatchRecordEntry.As per my current Page_load function, I am lossing my DataGrid when I clicked Edit LinkButtton. So it seems to me that Postback is not working. It's driving me nuts.................Help me................Current Page_Load function is as follows.***************Sub Page_Load(ByVal sender As Object,ByVal e As EventArgs)'---if loading for the first time, set the page size and also the page indexIf Not Page.IsPostBack then dtgrid.CurrentPageIndex = Session("curr_page") Panel1.Visible = True Load_Data()End IfEnd Sub****************************Now I tried to put Load_Data() funtion in else part like as follows in Page_Load function and another problem arise.***************Sub Page_Load(ByVal sender As Object,ByVal e As EventArgs)'---if loading for the first time, set the page size and also the page indexIf Not Page.IsPostBack then dtgrid.CurrentPageIndex = Session("curr_page") Panel1.Visible = True Load_Data()else Load_Data()End IfEnd Sub****************************The IInd problem is " when I click on edit Linkbutton, I get TextBox in my DataGrid. I can change in the Textbox but when I click on Update LinkButton, I am getting Old values but not the changed values in my Update SQL stmt." I have removed else part in my following code........I really appreciate ur time, help.I will be waiting for ur positive reply with solution
Stalling at the .ExecuteReader   (381 Views)
I am relatively new to ASP.NET and was given what should have been a simple program. I'm supposed to read a visitor database(MS SQL) and pull valid information on current visitors. Here is where I'm at (including some response.write's to see where I'm getting) Imports System.Data Imports System.Data.SqlClient Imports System.Web.UI.WebControls Imports System.IO Partial Class vSearch Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load CType(Me.Master, IntranetMaster).PageTitle = "Visitor Search" Response.Write("1>>>> I'm in the page load") 'End Sub 'Private Function visitorSearch(ByVal strName As String) Response.Write("2>>>> I'm in the function") Dim visitorConnection As New SqlConnection Dim visitorCommand As New SqlCommand Dim visitorReader As SqlDataReader Dim visitorQuery As String Dim tr As TableRow Dim tc As TableCell Dim visitorName As String Dim visitorDepartment As String Dim visitorHost As String Dim visitorPicture As String Dim visitorPhone As String Dim visitorExt As String Dim visitorEMail As String Dim visitorContent As String Dim visitorHasPicture As String Dim visitorHasNoPicture As String Dim imagePath As String Dim visitorShowImage As String Try Response.Write("3>>>> I'm in the try") 'connection to SQL database visitorConnection.ConnectionString = "Data Source=SQLtest;Initial Catalog=EmployeeList;Integrated Security=True" visitorConnection.Open() Response.Write("4>>>> " & visitorConnection.ConnectionString) 'SQL querry that preformats visitorName and visitorPhoto for filename search 'needs to be replaced with a stored procedure at a later date visitorQuery = "SELECT FirstName + ' ' + LastName + ' - Visitor' AS visitorName, [Department],[Supervisor],[Phone Number],[Extension],[EmailAddress],LastName + '_' + FirstName + '.jpg' AS visitorPhotoFROM([EmployeeList].[dbo].[NonEmployees])WHERE Inactive '1'ORDER BY LastName" visitorCommand.CommandText = visitorQuery visitorCommand.CommandType = CommandType.Text 'visitorCommand.Parameters.Add("name", SqlDbType.VarChar, 20).Value = strName visitorCommand.Connection = visitorConnection Response.Write("5>>>> " & visitorQuery) imagePath = System.Configuration.ConfigurationManager.AppSettings.Get("ImageDirectory") Response.Write("6>>>> " & imagePath) visitorReader = visitorCommand.ExecuteReader Response.Write("7>>>> I'm past the reader") If visitorReader.HasRows Then Response.Write("8>>>> I'm in the if") While visitorReader.Read() tr = New TableRow tc = New TableCell visitorName = visitorReader("visitorName") visitorDepartment = visitorReader("Department") visitorHost = visitorReader("Supervisor") visitorPicture = visitorReader("visitorPhoto") visitorExt = visitorReader("Extension") visitorEMail = visitorReader("EmailAddress") visitorHasPicture = imagePath & visitorPicture visitorHasNoPicture = imagePath & "NoPictureAvailable.jpg" Response.Write("" & visitorHasPicture) 'set the image If (File.Exists(visitorHasPicture)) Then visitorShowImage = visitorHasPicture Else visitorShowImage = visitorHasNoPicture End If 'set the phone number If visitorReader("Phone Number") "" Or "na" Or "NULL" Then visitorPhone = visitorReader("Phone Number") Else visitorPhone = "" End If 'set Extension If visitorExt = "" Or "NULL" Then visitorExt = "" End If 'format the visitor information visitorContent = "" & visitorName & "" & visitorEMail & "" _ & "Dept: " & visitorDepartment & "Host: " & visitorHost & "" 'create the table tc.Text = visitorContent tr.Cells.Add(tc) tc = Nothing Me.tblVisitor.Rows.Add(tr) tr = Nothing End While 'visitorSearch = True 'Else 'visitorSearch = False End If visitorReader = Nothing visitorCommand = Nothing visitorConnection.Close() Catch ex As Exception End Try End Sub End Class In particular when I view the website in a browser, I get to this point(6) and no further: imagePath = System.Configuration.ConfigurationManager.AppSettings.Get("ImageDirectory") Response.Write("6>>>> " & imagePath) visitorReader = visitorCommand.ExecuteReader Response.Write("7>>>> I'm past the reader") Any ideas I'm just trying to get an idea of what I may or may not be doing before I go in to my supervisor and ask her for help.
my computer   (326 Views)
how to open mycomputer on clicking a butten in using me code behind page
Sum Selected lines from gridview   (157 Views)
senario: have a gridview with a column that is a checkbox so user can select 1 or more rows.sum selected rowsproblem:Tried do this without update panels/ajax and all did okwith ajax enabled when i hit the button it unselect all rows that were selected before and dont find any selected row is a part of the page as markup. Protected Sub ButtonCalcula_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ButtonCalcula.Click Dim i As Integer For i = 0 To GridViewDetalhes.Rows.Count - 1 Dim dgItem As GridViewRow = GridViewDetalhes.Rows(i) Dim lblid As Label = CType(dgItem.FindControl("labelDocID"), Label) Dim isChecked As Boolean = CType(dgItem.FindControl("CheckBoxPagar"), CheckBox).Checked 'If isChecked Then Soma = Decimal.Parse(dgItem.Cells(3).Text) + Soma 'End If Next i TextBoxAPagar.Text = Soma End Sub ps: only now noticed i posted in wrong forum, its late here and i am almost sleeping. if a moderator can plz move my topic to This post has been edited by He-Man: 13 July 2008 - 04:45 PM
How To Get This To Work :p   (214 Views)
I've written a small file called edit.asp and everything seems fine except I get the error msg that says: "Error Type: Microsoft VBScript compilation (0x800A0401) Expected end of statement /lan/edit.asp, line 25, column 105" So I've checked the line, and dubble checked and I can find no error. So my conclusion is that while me not beeing too experienced with asp it must be a very small error that just slips passed my eyes.
lan messenger in asp .net   (455 Views)
, i want create a online lan messenger in for my office users there is number of user in office . i wants to do like a website which run on a local computer through lan and other will access it through browser by its IP address. if any one can help me over it please email me on This post has been edited by macosxnerd101: 03 September 2011 - 11:46 AM Reason for edit:: Email removed per site policies. Please keep all work via the forums
Regarding the Recurring Payment process   (131 Views)
Hi I need to use recurring billing for my work with verisign as partner.I have done this with paypal. Could you please guide me how to do this with credit card with verisign as partner. Could you please provide any reference link to know about this. Thank you in Advance.
Divide column 3-3 wise   (195 Views)
I have the table having 50 fields. some are classes, academic year,schoolid, scboys,scgirls,st boys,st girls.... but i want to display data as classwise Class6th Class 7th Schoolid Caste Boys Girls Total Boys girls Total 1 sc 10 4 14 2 4 6 st 1 2 3
Image Upload   (171 Views)
Hi... While trying to upload a image the error commimg as Specified cast is not valid. error in line 184. Line 182: while (dr1.Read()) Line 183: { Line 184: IMGID =(int)dr1[0]; Line 185: } Line 186: dr1.Close(); using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Data.SqlClient; using System.IO; public partial class admin_image_upload : System.Web.UI.Page { Itutorconnection mycon = new Itutorconnection(); SqlCommand cmd; SqlDataReader dr; SqlDataAdapter da; DataTable dt; string sql; public string imgstr = ""; int imgid = 0; protected void Page_Load(object sender, EventArgs e) { Label1.Visible = false; Label2.Visible = false; if (!Page.IsPostBack) { fillgrid(); Session["flag"] = 0; } } public void fillgrid() { sql = "SELECT * FROM WS_IMAGE"; da = new SqlDataAdapter(sql, mycon.icon); dt = new DataTable(); da.Fill(dt); if (dt.Rows.Count > 0) { GridView1.DataSource = dt; GridView1.DataBind(); } else { dt.Rows.Add(dt.NewRow()); GridView1.DataSource = dt; GridView1.DataBind(); int totalcolumn = GridView1.Rows[0].Cells.Count; GridView1.Rows[0].Cells.Clear(); GridView1.Rows[0].Cells.Add(new TableCell()); GridView1.Rows[0].Cells[0].ColumnSpan = totalcolumn; GridView1.Rows[0].Cells[0].Text = "No Record Found"; } } public void filltextbox(int id) { sql = "SELECT * FROM WS_IMAGE WHERE IMGID=" + id; cmd = new SqlCommand(sql, mycon.icon); dr = cmd.ExecuteReader(); if (dr.HasRows) { while (dr.Read()) { txt_title.Text = dr["TITLE"].ToString(); txt_descr.Text = dr["DESCR"].ToString (); txt_headertitle.Text = dr["HTITLE"].ToString(); if (!dr.IsDBNull(4) && dr["UPIMG"].ToString().Trim().Length > 0) { imgstr = ""; } else { imgstr = ""; } ddl_catagory.Text = dr["CATAGORY"].ToString(); } } dr.Close(); cmd.Dispose(); } protected void btn_save_Click(object sender, EventArgs e) { int i = 0; int check =(int)Session["flag"]; string img_newFileName = ""; string IMGID_newFileName = ""; string FileExt_new = ""; int IMGID_new_filesize = 0; string img_delete = ""; string IMGID_delete = ""; string Image_Name = ""; string IMGIDeo_Name = ""; int IMGID = 0; if (fileup_img.HasFile) { if (check == 0) { if ((fileup_img.PostedFile != null) & (fileup_img.PostedFile.ContentLength > 0)) { Image_Name = Image_Id(); if (Image_Name == "Invalid Format") { Label1.Visible = true; return ; } if (Image_Name == "OverSize") { Label2.Visible = true; return ; } } } if (check == 1) { sql = "SELECT UPIMG FROM WS_IMAGE WHERE IMGID=" + GridView1.DataKeys[GridView1.SelectedIndex].Value; cmd = new SqlCommand(sql, mycon.icon); dr = cmd.ExecuteReader(); if (dr.HasRows) { while (dr.Read()) { img_delete = dr[0].ToString(); } } dr.Close(); cmd.Dispose(); File.Delete(Server.MapPath("StoredImages") + img_delete); string[] Split_Array = null; Split_Array = img_delete.Split('.'); int Split_ImgId = Convert.ToInt32(Split_Array[0].Remove(0, 5)); Image_Name = Save_Image(Split_ImgId);//Calling a Function if (Image_Name == "Invalid Format") { Label1.Visible = true; return; } if (Image_Name == "OverSize") { Label2.Visible = true; return; } } } if (check == 1) { sql = "UPDATE WS_IMAGE SET TITLE='" + txt_title.Text.Trim() + "',DESCR='" + txt_descr.Text.Trim() + "',HTITLE='" + txt_headertitle.Text.Trim() + "',CATAGORY='" + ddl_catagory.SelectedItem.Text + "' WHERE IMGID=" + GridView1.DataKeys[GridView1.SelectedIndex].Value + ""; cmd = new SqlCommand(sql, mycon.icon); cmd.ExecuteNonQuery(); cmd.Dispose(); Session["flag"] = 0; Response.Redirect("image_upload.aspx"); } if (check == 0) { cmd = new SqlCommand("SELECT MAX(IMGID) FROM WS_IMAGE", mycon.icon); SqlDataReader dr2 = default(SqlDataReader); dr2 = cmd.ExecuteReader(); if (dr2.HasRows) { if (dr2.Read()) { if (dr2[0] == System.DBNull.Value == true) { IMGID = 1; } else { cmd = new SqlCommand("SELECT MAX(IMGID)+1 FROM WS_IMAGE", mycon.icon); SqlDataReader dr1 = default(SqlDataReader); dr2.Close(); dr1 = cmd.ExecuteReader(); if (dr1.HasRows) { while (dr1.Read()) { IMGID =(int)dr1[0]; } dr1.Close(); cmd.Dispose(); } } } } dr2.Close(); cmd.Dispose(); cmd = new SqlCommand(); cmd.Connection = mycon.icon; cmd.CommandText = "INSERT INTO WS_IMAGE VALUES(" + IMGID + ",@title,@descr,@header,@image,@catagory)"; cmd.Parameters.AddWithValue("@title", txt_title.Text.Trim()); cmd.Parameters.AddWithValue("@descr", txt_descr.Text.Trim()); cmd.Parameters.AddWithValue("@header", txt_headertitle.Text.Trim()); cmd.Parameters.AddWithValue("@image", Image_Name); cmd.Parameters.AddWithValue("@catagory", ddl_catagory.SelectedItem.Text); cmd.ExecuteNonQuery(); cmd.Dispose(); Response.Redirect("image_upload.aspx"); } fillgrid(); } public string Image_Id() { string img_name = ""; cmd = new SqlCommand("SELECT MAX(IMGID) FROM WS_IMAGEID", mycon.icon); dr = cmd.ExecuteReader(); if (dr.HasRows) { if (dr.Read()) { imgid = Convert.ToInt16(dr[0].ToString().Trim()); } } dr.Close(); cmd.Dispose(); imgid = imgid + 1; img_name = Save_Image(imgid); //Calling Another Function sql = "UPDATE WS_IMAGEID SET IMGID='" + imgid + "'"; cmd = new SqlCommand(sql, mycon.icon); cmd.ExecuteNonQuery(); cmd.Dispose(); return img_name; } public string Save_Image(int getImgId) { string img_filename = ""; string FileExt = ""; int img_maxheight = 250; int img_maxwidth = 250; HttpFileCollection httpfilecol = Request.Files; HttpPostedFile file = httpfilecol[0]; string FileName = Path.GetFileName(file.FileName); FileExt = Path.GetExtension(file.FileName).ToLower(); if (FileName != string.Empty) { if (FileExt != ".swf" & FileExt != ".jpg" & FileExt != ".gif" & FileExt != ".jpeg" & FileExt != ".tiff" & FileExt != ".tif" & FileExt != ".png" & FileExt != ".bmp") { return "Invalid Format"; } img_filename = "image" + getImgId + FileExt; file.SaveAs(Server.MapPath("../StoredImages/") + img_filename); } return img_filename; } protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e) { GridView1.PageIndex = e.NewPageIndex; GridView1.DataBind(); fillgrid(); } protected void GridView1_SelectedIndexChanged(object sender, EventArgs e) { int rowid = (int)GridView1.DataKeys[GridView1.SelectedIndex].Value; filltextbox(rowid); Session["flag"] = 1; } protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { sql = "DELETE FROM WS_IMAGE WHERE IMGID=" + GridView1.DataKeys[e.RowIndex].Value; cmd = new SqlCommand(sql, mycon.icon); cmd.ExecuteNonQuery(); cmd.Dispose(); Session["flag"] = 0; clear(); fillgrid(); } public void clear() { Response.Redirect("image_upload.aspx"); } }
Filtering Comments By Username   (125 Views)
I am trying to filter comments by username on my website the process is select a username from the dropdownlist once selected the comments posted by the selected username will display i am stuck on this any ideas given pls. Textchanged once selected from the dropdownlist: protected void DPList_TextChanged(object sender, EventArgs e) { string table = "SELECT * FROM Comments WHERE CommentUsername = @Username"; try { SqlCommand command = new SqlCommand("SELECT * FROM Comments WHERE CommentUsername = @Username", c.connection); c.connection.Open(); command.Parameters.AddWithValue("@Username", DPList.Text); SqlDataReader datareader = command.ExecuteReader(); while (datareader.Read()) { DataTable dt = new DataTable(); dt = DPList.SelectedItem.ToString(); GVComments.DataSource = dt; GVComments.DataBind(); } datareader.Close(); } catch (SqlException) { } finally { c.connection.Close(); } }
Paging a datalist - revised question   (348 Views)
I am a newbie (with a little experience - mostly trial and error) who has followed a tutorial re a datalist pager. The tutrial expects its audience to be more experienced than me. ie it expects students to know what goes at the top of the code behind page ( "imports" in VB / "using" in C# ) and it expects students to adjust Visual Studio property / events without any guidence in order for its code to work. I have managed adjustments in VWD user interface properties / events window which brought all the pagers facial functions to life but it appears that I am missing the one vital step for it to actually adjust the page size. The pager control ( see trial ftp page here - ) seems to think its working. Below I say what it actually does do : It knows how many records are in the db field because it diplays the right amount of page numbers.and it adjusts the amount of page numbers according to the page size options in its dropdown list. It highlights which page it believes it is on once a user chooses a page. It knows which records it is supposed to be displaying - ie "previous" and "next" buttons react properly re clicking on last link or first link. I think the problem is in the properties events section of VWD user interface or is another very basic mistake because I am as sure as I can be that my code is the same as the lessons which gets excellent response reviews from very many other people who have used it. The lesson I followed is here - - and its working example is here - can anyone help If its any help - I think the likely foundation of my mistake is basic - along the lines of this being the first time I have ever used C# instead of having the page set up for VB - or my very limited knowledge re which events or properties to adjust from the default settings in my VWD 2008 express user interface to implement the pager. I adjusted a few events connected to the paging datalist and its associated controls which did made the controls on the pager spring to life. The .aspx page code is below and below that is the .aspx.cs page - I laso attach the 2 files in a zip folder if that helps. aspx code:- Previous 40 50 100 Next .aspx.cs code :- using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data; using System.Data.SqlClient; public partial class WholesaleCSHARP_2 : System.Web.UI.Page { PagedDataSource pds = new PagedDataSource(); private void BindGrid() { string sql = "SELECT [ProductCode], [ImgUrl], [Featuring], [Title] FROM [TableSG1] ORDER BY [Featuring]DESC "; SqlDataAdapter da = new SqlDataAdapter(sql, "Data;Initial Catalog=DB_5554_maindb1;User ID=DB_5554_maindb1_user;Password=bootsie23000;Integrated Security=False;"); DataTable dt = new DataTable(); da.Fill(dt); pds.DataSource = dt.DefaultView; pds.owPaging = true; pds.PageSize = Convert.ToInt16(ddlPageSize.SelectedValue); pds.CurrentPageIndex = CurrentPage; lnkbtnNext.Enabled = !pds.IsLastPage; lnkbtnPrevious.Enabled = !pds.IsFirstPage; DataList1.DataSource = dt; DataList1.DataBind(); doPaging(); } protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { BindGrid(); } } public int CurrentPage { get { if (this.ViewState["CurrentPage"] == null) return 0; else return Convert.ToInt16(this.ViewState["CurrentPage"].ToString()); } set { this.ViewState["CurrentPage"] = value; } } private void doPaging() { DataTable dt = new DataTable(); dt.Columns.Add("PageIndex"); dt.Columns.Add("PageText"); for (int i = 0; i < pds.PageCount; i++) { DataRow dr = dt.NewRow(); dr[0] = i; dr[1] = i + 1; dt.Rows.Add(dr); } dlPaging.DataSource = dt; dlPaging.DataBind(); } protected void dlPaging_ItemCommand(object source, DataListCommandEventArgs e) { if (e.CommandName.Equals("lnkbtnPaging")) { CurrentPage = Convert.ToInt16(e.CommandArgument.ToString()); BindGrid(); } } protected void lnkbtnPrevious_Click(object sender, EventArgs e) { CurrentPage -= 1; BindGrid(); } protected void lnkbtnNext_Click(object sender, EventArgs e) { CurrentPage += 1; BindGrid(); } protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e) { CurrentPage = 0; BindGrid(); } protected void dlPaging_ItemDataBound(object sender, DataListItemEventArgs e) { LinkButton lnkbtnPage = (LinkButton)e.Item.FindControl("lnkbtnPaging"); if (lnkbtnPage.CommandArgument.ToString() == CurrentPage.ToString()) { lnkbtnPage.Enabled = false; lnkbtnPage.Font.Bold = true; } } protected void dlPa(object source, DataListCommandEventArgs e) { } } THANKS FOR ANY GUIDENCE OFFERED Attached File(s) (1.86K) Number of downloads: 120
Asp.Net Applications related to banking   (228 Views)
Hii Guys, This is harish here...I want to know what are the kind of asp applications we can develop for Banking domain.Can u just illustrate me with some examples.. How to gather information about these things.. Waiting for u'r reply. Harish
How would an ASP .NET web application handle constant user requests?   (209 Views)
I want to make a text based MMORPG in C# and ASP .NET. The game will involve constant, continuous updates for example the character/skill experience a player has. My question is, how would I store/update those skill experience variables Would I update the SQL Server database every single time a change is made to the "experience points" variables or would I only update the database at certain time intervals What state management would be best to store such data that is continously updating and is private to each user How might the requirements/techniques need to be changed if the website/web application becomes extremely popular with heavy traffic
Multiple text colors   (257 Views)
I am new to c# programing and now creating c# web application, i want to display different words with different colors using a textbox. is there any way to do it , Given that this is web forms, not win forms, I'm going to move the post. Also, TextBoxes render to tags. HTML is styled with CSS, so you should look up what styles you would need to use to achieve your deed effect. , Why are people who don't know how to program doing thesis work I don't get it. You had years to learn how to program, and now you're running to us on the internet expecting us to teach you how to change the color of a text box for your thesis! Did you sleep through the last three years of school I wouldn't be this harsh if you had been willing to do the slightest bit of research. I gave you all the keywords you need to do a google search to get tutorials. HTML, Input, style. String that together into a question and you'll get thousands of help articles. But no, you have to say "someone pls tell me how to do it!!! ". No.
asp project readymade for my final yr required urgently   (207 Views)
Is there anyone who can send me their asp project I shall pay
DB Connection problem   (328 Views)
Hi. I am used to working with classic asp. Now I want to set my db connection in a class and call a seperate class to get the records from the db. I get the following msg: Exception Details: System.Data.SqlClient.SqlException: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) Below is my code. in my DbConnect.cs is using System; using System.Data; using System.Configuration; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Data.SqlClient; /// /// Summary description for DbConnect /// public class DbConnect { SqlConnection myConnection; public DbConnect() { myConnection = new SqlConnection("Server=(local);" + "Database=database;" + "Trusted_Connection=True;" + "connection timeout=30"); } public void Open() { myConnection.Open(); } public SqlDataReader Select(string sqlQuery) { SqlCommand myCommand = new SqlCommand("Command String", myConnection); SqlDataReader myReader = myCommand.ExecuteReader(); return myReader; } public void Close() { try { myConnection.Close(); } catch (Exception e) { Console.WriteLine(e.ToString()); } } } and then in my code is: DbConnect myCon = new DbConnect(); myCon.Open(); SqlDataReader myReader = myCon.Select("Select * from tblUser"); while (myReader.Read()) { Console.WriteLine(myReader["pageTitle"].ToString()); Console.WriteLine(myReader["pageContent"].ToString()); } myCon.Close();
Doing error checking with ListView   (226 Views)
Alright, I've got a ListView going that's been databinded with a local database file and all that and has Deleting, Editing, and Inserting enabled and all that. Works fine. But what I don't know how to do is how do I do some error checking with this There are boxes next to Insert button that they can fill out and whatnot. But I want to make sure the data they input is correct. And to do that I need to access the textboxes inside this ListView and make sure they are the way I need them. How do I go about doing that I've looked at the TextBox ID="whatever" thing in the code in hopes that I could access it by doing whatever.Text = blah. That obviously doesn't work. Any ideas I'm sure this has to be possible.
How to work with two tables - your input is greatly appreciated   (240 Views)
hi,I'm new to development. I have two tables that carry the same primary key. Here's what I want to do: 1. iterate through the main table first, then inside that loop, I want to check my other table for the same key. 2. If it's the same key, I concatenate values of a parricular column in the second table until the key changes. I then want to add this field of concatanated data into my first table. The reason why I am doing this is I need to have the data in one row for a data grid. Does that seem like a normal thing to do in If I create a data relation between these two tables, how would I use it in such a case I am not sure how to implement it.
UserControl drawing / funciotn issues   (247 Views)
I have a menu that is set up as a user control. The buttons on the control all work, so the code behind is being called.Now for ease of use, I wish to change the enabled / disabled status of some of the buttons depending on who is logged on / off. But the code (placed in the control constructor function) is not executing (I have placed a breakpointon it and it is never called).If I put the code on a page, and use it I can toggle a buttons enabled state, so I know that the code works, its just accessing it through the control.So I assume that there is a method I need to add to my control that is called whenever it is drawn, as if I need to add in code in each page that uses the menu, then I lose the benefits of having a user control.if it was C++ It would be something like the OnDraw() function, but that doesnt work in Vis Studio. Any advice / help greatfully receivedK on citrix   (164 Views)
I Need some information regarding installation of visual on citrix and also can IIS be installed remotely on some other machine.if so ,can IIS handle running different applications at same time (training people in a class)
My machine keeps cgraching, please help.   (259 Views)
Here is a post from somebody that has the same problem. Is this a known issue Is there a fix for itI would like to use VS.NET 2003 soon again.Any help is appreciated.Thank you,Steve ASP.Net application times out, locks up computer Posted: 03-13-2005 08:04 AM I have the strangest problem, never had this problem before on any machine. I open an c# web project with VS.Net 2003. It opens fine. I then either open my web browser and go to http://localhost/mywebproject/default.aspx, or I run the application from within VS.Net. It opens fine. However, when I make the slightest change to my default.aspx file, even just adding a space and then deleting it and saving the .aspx file, then "refresh" the browser (using IE 6.0), the website just sits there as though it's taking awhile to refresh...but it never refreshes. If I try to do anything else on my machine, such as look at Task Manager, the machine completely locks up. I actually just let the machine do its thing for about 20-25 minutes (yeah, it took that long) and then this message finally came up: "Time out waiting for a program to execute. The command being executed was "c:\windows\\framework\v1.1.4322\csc.exe" /noconfig @"C:\Windows\Microsoft.Net\Framework\v1.1.4322\Temporary ASP.Net Files\remarkablecoffees\903d4e45\d6bbf567\uir21m1b.cmdline". I've search the internet like crazy looking for a possible reason why this happens, can't find anything. If anyone has any way to figure this out I would be very, very appreciative. I've tried reloading Visual Studio to repair it, didn't help. I'm currently running Windows XP SP 2 with all windows updates installed. For the time being I'm going to just run all ASP.Net applications on my windows 2003 server so I can get some work done.
Which Control caused PostBack?   (250 Views)
I have a dropdown list and button that cause postback, each with events that are getting fired correctly after Page_Load. How can I determine which control caused the postback in OnInit()
Header Control Assistance Please   (319 Views)
I know this is an easy fix but I'm not seeing what could be the problem. Anyways I am reading C# Web Applications with Visual Studio .NET. I read in one of the chapters you can make a base class file that you can format all your web pages the same like a template html. Well the example has a header and footer section the rest of the page would be created by me. This is what I want to do I got the footer control made with no problem but my Header when I view it in design mode its what I want. Here is the code:CODE The textHeader and imageHeader are two transparent images. The bgheader is a gradiant background image. Like I stated early it looks correct but when I run it the two transparent images take the white background instead of my color one.Any tips or suggestions be greatly appreciated.
ASP.NET   (170 Views)
I am trying to get the value of tag. Here is my example.I haveTest1Test2I want to get this value using ASP.Net. I am using Request.Form("select1"), Getting only the value but not text. Any inputs
Datagrid Print Question   (194 Views)
When i print my datagrid it only prints the gridlines on the first page and not on any of the following pages. Also, it doesn't print the shading that I have on the grid. Does anyone know how to fix thi
Altering an A tag within a string...   (319 Views)
Merry Christmas all!What I want to be able to do is to take a string of HTML and check if there are any 'A' (link) tags that do not have a 'class' attribute and if there are, then add the class attribute to any of the 'A' tags that are lacking one. So, if I had:This is some text and here is a link and here is another linkI'd like to end up with:This is some text and here is a link and here is another linkI'm completely stumped as to how I would achieve this.
Custom Server Control Property Editor   (215 Views)
Hi Folks!Need some help.Building a Customer WEB Server Control using VB.NET and I am trying to set the Editor Attribute to the following property: _Property [BackButtonImage]() As String Get Return _BackButtonImage End Get Set(ByVal Value As String) _BackButtonImage = Value End SetEnd PropertyThe above code is suppose to work by adding Imports System.ComponentModel. But it is not working. I have searched the InterNut for several hours but all the examples/documention keep pointing me back to this. However the error I keep getting is "Design is not a member of UI" I have ran out of ideas. This is what I get from the Object BrowserPublic Class ImageUrlEditor Inherits System.Web.UI.Design.UrlEditor Member of System.Web.UI.Design Wayne Sellars"Programming, today is a race between software developers, striving to build bigger and better idiot-proof programs, and the Universe, trying to produce bigger and better idiots. So far, Universe 1 - Programmers 0."
VS Data formatting in textboxes   (276 Views)
In Visual Studio, is it possible to format data in textboxes For example, how could a currency value of 50 be displayed as 50.00
Spell Checking   (220 Views)
Does anyone know of a good way to do spell checking in an ASP.Net application I am using a form to send an email and I would like the option to check spelling before sending the email.
targetSchema - How will this work, REALLY?!?   (243 Views)
I just came across the property "targetSchema". I am looking for a stronger understanding of this property and how it might be beneficial in the practical world. From what I understand, one would create a web form and place server controls on it. The targetSchema property can be set to a browser version. By default it is IE5. There is also the ability to create new targetSchemas for the server to run. Sounds cool so far!!! I like the fact that the server will generate additional html code that as a developer, I used to write. What about an internet web site, where as a web site administrator, one needs to worry about the different browser version: IE4,NS4,IE5,NS6,MacIE5...and so on... If I select an individual targetSchema, say IE5, then won't the server generate all of the code for this schema and ignore the fact that an end-client user may actually be using a different browser than the schema that I have selected. Is this another tactic by MS to dominate the browser war OR Do I need to learn more about the .NET technology For the record, I am a Microsoft fan. However, like so many, I become frustrated in having to write for different standards.Any insight and thoughts would be appreciated!!
[ASP.NET]: howto read client devices (like usb pendrive) via web?   (333 Views)
Hi all!I must to read and write from/to a specified usb pendrive insert into my client pc via web.I'm trying to open a web page, list all client dviers (C:\,D:\ ... ), click on a driver, and if is an removable device write a txt file or (reverse operation) read a txt !I've tried some code about drivers listing, but this reads only local (so if I run the page from my iis serve, I view server drivers not my local ones).Any solution or ideaMany thanks for all posts, and sorry for my english the bestFrancesco Cabigliera - Italy Francesco Cabigliera "Tadan"----------------------------Italiano Amateur Radio Station----------- IW3IDS ---------On Echolink - APRS Active
Java to ASP.NET   (200 Views)
Has anybody been involved in migrating java to using Microsoft JCLA, or suggestions where I can get metrics from I've got a project which potentially involves translating a JSP package onto the 'strategic' platform but nobody has any idea how big a task it is.
disable page   (391 Views)
How to disable page(make it gray) while loading data on to it I'm using ajax updatepanel.
Validation Application Block and serialisation   (207 Views)
Hi allIs it possible to configure a business entity on the server and to apply validation using the validation application block in such a way that the validation is available on the client when using web servicesI want to configure my validation in one place. Matt
Custom Server Control's click event not firing   (422 Views)
are the events wired to the controlsI prefer to explicitly wire my events in the Init event instead of using declartive markup.CODEpublic class MyPage : Page{ public MyPage() { Init += WireEvents; } private void WireEvents(object sender, EventArgs e) { MyButton.Click += ClickMyButton; } private void ClickMyButton(object sender, EventArgs e) { //do work here }}markup would look like thisCODEprotected void ClickMyButton(object sender, EventArgs e){ //do work here} Jason MeckleyProgrammerSpecialty Bakers, Inc.
Problem with date picker   (252 Views)
I'm using the calendar control on my webpage. The pop up works fine, however when I select the a date the pop does return the value selected to the text box ... it doesn't seem to do anything.can anyone help Here's the code on aspx page:CODE Calendar Actual Calendar aspx:CODE{/CODE}Code behind the Calendar.aspx form:[CODE]public partial class Calendar : System.Web.UI.Page{ protected void Page_Load(object sender, EventArgs e) { } protected void Calendar1_SelectionChanged(object sender, EventArgs e) { string strjscript = ""; strjscript += "window.opener." + HttpContext.Current.Request.QueryString["formname"]; strjscript += ".value = '" + Calendar1.SelectedDate.ToString("d") + "';window.close();"; strjscript += ""; //Don't ask, tool bug. Literal1.Text = strjscript; } protected void Calendar1_DayRender(Object source, DayRenderEventArgs e) { if (e.Day.Date.ToString("d") == DateTime.Now.ToString("d")) { e.Cell.BackColor = System.Drawing.Color.LightGray; } }
Programmatically show/hide a table row   (304 Views)
Hi allI am developing an application in that allows a user to select a number of items via checkboxes, dropdown lists etc.The results page needs to show the items selected by the user and the value for that selection in a table.I can get all the items to show and if selected their value, but i need to be able to hide the name of the item selected and its value if it is not selected by the user.Could someone please advise me how to do thi