|
Hi am binding the Data in the dropdownlist(cboYY).But after selecting the value am not getting the selected value always getting selectedIndex=-1 and the selected value is getting Null that code as follows
string a =Convert.ToString(cboYY.SelectedIndex);
string b = cboYY.SelectedValue;
Databinding code as follows
private void bindYear()
{
DataTable YearTable = new DataTable();
DataColumn YearColumn;
YearColumn = new DataColumn();
YearColumn.DataType = Type.GetType("System.String");
YearColumn.ColumnName = "dobYear";
YearTable.Columns.Add(YearColumn);
YearTable.Rows.Add("YYYY");
for (int i = 1940; i <= DateTime.Now.Year; i++)
{
YearTable.Rows.Add(i);
}
if (YearTable.Rows.Count > 0)
{
cboYY.DataSource = YearTable;
cboYY.DataBind();
}
YearTable.Dispose();
}
|
|
|
|
|
hi
if u use following code in page_load then all
code use within
if(!Page.IsPostback)
{
///statemane of ur programm here
}
no knowledge in .net
|
|
|
|
|
it is Listing all the values in the dropdownlist but when i select any value am not getting that value.getting selected value=null or selectedindex=-1
|
|
|
|
|
Just check whether you have viewstate enabled or not for the dropdown list.
Don't Quit
|
|
|
|
|
u can try
this
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
bindYear();
}
}
private void bindYear()
{
DataTable YearTable = new DataTable();
DataColumn YearColumn;
YearColumn = new DataColumn();
YearColumn.DataType = Type.GetType("System.String");
YearColumn.ColumnName = "dobYear";
YearTable.Columns.Add(YearColumn);
YearTable.Rows.Add("YYYY");
for (int i = 1940; i <= DateTime.Now.Year; i++)
{
YearTable.Rows.Add(i);
}
if (YearTable.Rows.Count > 0)
{
cboYY.DataSource = YearTable;
cboYY.DataTextField = "dobYear";
cboYY.DataBind();
}
YearTable.Dispose();
}
protected void btn_Click(object sender, EventArgs e)
{
string a = Convert.ToString(cboYY.SelectedIndex);
string b = cboYY.SelectedValue;
msg.Text = a + b;
}
no knowledge in .net
|
|
|
|
|
Kurian_Kurian wrote: string a =Convert.ToString(cboYY.SelectedIndex);
string b = cboYY.SelectedValue;
I guess this you have written this in class and not in any methods. So this value will be set when the class instantiated. At that time dropdown selectedindex will be -1.
|
|
|
|
|
I am looking for a way to list files and folders in my IIS Directory. I want the users to be able to check a box to delete old outdated pdf’s. They also have to be able to sort by name, date, and size of the file.
Does any have a link to some code I can use?
|
|
|
|
|
Directory.GetAllFiles will return a string array which is a valid data source for a data driven control.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I have tried till my eyes bled to get a gridview to work so I have resorted to going back to the traditional asp recordset. I still have nothing showing up. Please help, this thing has been stomping me for a week. (FYI I am new to development in general...please have mercy )
Here is my code:
<%
Dim strShift, strType, strDate, objRS, strSQL, objConn, strConn, strShiftPull, strTypePull, rShift, rType
strDate = Request.QueryString("OccDate")
strShiftPull = Request.QueryString("pShift")
strTypePull = Request.QueryString("pType")
'Set shift query variables.
If strShiftPull = "IP1" Then
rShift = "1"
End If
If strShiftPull = "IP2" Then
rShift = "2"
End If
If strShiftPull = "IP3" Then
rShift = "3"
End If
If strShiftPull = "IP Supplier" Then
rShift = "8"
End If
If strShiftPull = "CMA1" Then
rShift = "4"
End If
If strShiftPull = "CMA2" Then
rShift = "5"
End If
If strShiftPull = "CMA3" Then
rShift = "6"
End If
If strShiftPull = "CMA Supplier" Then
rShift = "7"
End If
'Set incident type query variables
If strTypePull = "Lost Time Accident" Then
rType = "1"
End If
If strTypePull = "Recordable" Then
rType = "2"
End If
If strTypePull = "Incident" Then
rType = "3"
End If
strShift = rShift
strType = rType
objConn = Server.CreateObject("ADODB.Connection")
objRS = Server.CreateObject("ADODB.Recordset")
strConn = "DSN=XXXX; driver={SQL Server}; UID=XXXX; PWD=XXXX;"
strSQL = "Select * from Safety_Data where Shift_ID = '" & strShift & "' and Xref_ID = '" & strType & "'"
objConn.open(strConn)
objRS.ActiveConnection = objConn
objRS.open(strSQL)
If Not objRS.EOF Then
Do While Not objRS.EOF
%>
<%
objRS.Fields("RID").value.ToString()
%>
<%
objRS.Fields("Notes").value.ToString()
%>
<%
objRS.MoveNext()
Loop
Else
Response.Redirect("NoIncRepFound.aspx")
End If
%>
Enter Record Number:<asp:textbox id="txtSelect" runat="server">
<asp:button id="cmdSubmit" runat="server" text="Submit"> |
|
|
|
|
|
BezerkRogue wrote: . (FYI I am new to development in general...
No offence, but if you're new to development entirely, why are you writing this sort of code ? Is this homework, or is someone paying for it ?
All of this is a disaster, you should never do any of the things you are doing in ASP.NET
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I am upgrading an application from asp 1.0 to 2.0. It seems like my old connection string for oracle doesn't work for this asp.net 2.0. No matter I read data or execute command, I always get this exception -- System.Data.OracleClient.OracleException: ORA-00911: invalid character at System.Data.OracleClient... which indicates the connection is not valid.
My connnection string is:
string connectionString = "Data Source=ora01;User ID=zd01;password=1234;Persist Security Info=True;";
OracleConnection con = new OracleConnection(connectionString);
con.Open();
I can't find any errors in this connection setting, the sql commmand is tested and working.
Any idea will be highly appreciated, Regards!
|
|
|
|
|
I have a user control that contains a repeater. By itself the repeater loads fast, as expected. Now, I've wrapped the control within an update panel, and the same repeater takes noticeably longer to load. Same data being displayed. Without the update panel, it loads is 2-3 seconds, with the update panel it is taking a minimum of 12-15 seconds, sometimes longer.
I have used other controls within the update panel, and have no noticable performance hit until now.
I've spent the last three days trying to get to the source of the poor loading repeater, and this is what I've narrowed it down to. Any suggestions are appreciated
I have used fiddler to analyze the two pages.
With Update Panel:
===========================
Request Count: 1
Bytes Sent: 52,193
Bytes Received: 856,032
ACTUAL PERFORMANCE
--------------
Requests started at: 20:27:40:4267
Responses completed at: 20:27:43:6299
Total Sequence time: 00:00:03.2031660
Without Update Panel:
=============================
Request Count: 1
Bytes Sent: 52,254
Bytes Received: 835,994
ACTUAL PERFORMANCE
--------------
Requests started at: 20:26:22:5351
Responses completed at: 20:26:24:6758
Total Sequence time: 00:00:02.1406524
So based on this output from fiddler, the pages both seem to be processing in pretty much the same time, a second longer for the oen with the update panel. BUT if the page only takes just over 3 seconds, why does it not complete the rendering for another 9-10 seconds (or longer).
Thanks in advance for any suggestions or input.
- Debbie
|
|
|
|
|
I have my own tables for a website. Is there a way to use the ASP .NET 2.0 LOGIN and user registration and specify an already made user table without having to use the tables that ASP .net generates when using asp .net membership? Thanks for your help.
|
|
|
|
|
Yes. The membership stuff is implemented using the Provider model. Simply substitute your own provider in and the login controls should work seamlessly.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Thanks for the reply. I will search for an article for a How To. Are there any articles that you know of on this subject? Thanks again.
|
|
|
|
|
Well, this[^] article might help as a starting point. Have yourself a 5 for wanting to go and look for yourself. Top show.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Well here is what I have:
I have a custom control MyCC deriving WebControl composed of an Image control and a Label control.
This custom control is defined in an assembly and used by an aspx.
Here is what I want to do:
I want to set the Image url at run time in the Render() method of MyCC.
How am I supposed to code that?
Setting the ImageUrl property of the Image with "~/Images/myImage.gif" doesn't work.
My assembly is defined like this:
Project Name: MyProject
Class component: MyProject.cs
Namespace: MyNameSpace
Class: MyCC
All images are stored in a folder: Images under MyProject.
Thanks for your help.
PS: Tell me if I'm in the wrong forum.
"Nothing is lost, Nothing is created, Everything is transformed" Lavoisier
|
|
|
|
|
The ImageUrl property of the Image control sets the url for the image to be displayed. So you need to add a property to your custom control for getting/setting the image url that internally maps to this property.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
pmarfleet wrote: So you need to add a property to your custom control for getting/setting the image url that internally maps to this property
Well, the Image is not set by the user but at render time because the image to set depends on different conditions.
What I need to know is how to build the URL dynamically in the Render() method so it would work wherever the control is used.
I'm looking for something like:
protected override void Render(HtmlTextWriter writer)
{
this._ico.ImageUrl = "imageUrl.gif";
this._ico.RenderControl(writer);
}
I just need to know how to build a correct URL as the image is embed in the custom control dll.
Thank you for your answers.
"Nothing is lost, Nothing is created, Everything is transformed" Lavoisier
|
|
|
|
|
I don't understand what you mean. In order to display an image, you need to specify the url of the image. The images would need to be stored as image files on your web server.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
pmarfleet wrote: The images would need to be stored as image files on your web server.
I understand that.
But how to do so when the images are defined with the custom control (within the custom control project).
Do I need to use a resource file?
"Nothing is lost, Nothing is created, Everything is transformed" Lavoisier
|
|
|
|
|
Firstly, Must be clear Url like;
Image.Url = "";
After that initialize image location, like;
Image.Url = "LOCATION";
|
|
|
|
|
Frankidoze wrote: Setting the ImageUrl property of the Image with "~/Images/myImage.gif" doesn't work.
That should work.
What do you mean when you say that it "doesn't work"? What does it do, and how does that differ from what you expect? Do you get any error message?
Experience is the sum of all the mistakes you have done.
|
|
|
|
|
It doesn't work because the image is not loaded when I run the page.
There is no error. It shows the traditional "image missing" image .
The situation is this:
My custom control MyCC is a class (it's not a user control) compiled into a dll.
All images I need to use for MyCC are defined in a folder named Images. So I guess they ended up in the dll somehow.
My page uses MyCC.
When MyCC is rendered, the image set for the Image control is not found because their is no such file on my web server.
In order to access those images from the page I guess they need to be extracted from the dll.
I want to defined those images with my class so wherever you use the control no extra step need to be done. Just drag the CC from the tool bar onto your page.
I guess at some point I need to manage those images as resources.
I hope my explanations will help you to help me.
"Nothing is lost, Nothing is created, Everything is transformed" Lavoisier
|
|
|
|
|
"Nothing is lost, Nothing is created, Everything is transformed" Lavoisier
|
|
|
|