|
How i can set the dropdownlist without using Selectindex property. Because in my repeater control (where i am displaying dropdownlist data) , i don't have assoicated listindex values, i just have dropdown list text.
I tried to use
((DropDownList)(FormView1.FindControl("CmbCountry"))).Text= "USA"; and i got erroe as below
has a SelectedValue which is invalid because it does not exist in the list of items.
Please help...
|
|
|
|
|
Amit Kumar G wrote: has a SelectedValue which is invalid because it does not exist in the list of items.
OK, so you're on the right track, but the text you tried to set does not appear in the list. Therefore, if you use a string that does appear in the list, this is the right way to set the value by text instead of index. Isn't there also a findindex method ? Or you can iterate over the Items collection to find the one you want, to ensure it is there.
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 )
|
|
|
|
|
oh dont worry...
its easy
just set dropdownlist_name.SelectedValue="USA"
now test it and enjoy...
msma
www.toolsfa.com
|
|
|
|
|
Dear Mohsen,
It is giving the same error
CmbCountry' has a SelectedValue which is invalid because it does not exist in the list of items.Parameter name: value
when i am doing
((DropDownList)(FormView1.FindControl("CmbCountry"))).SelectedValue = "USA";
|
|
|
|
|
test this code:
for (int i = 0; i < [your repeater].Rows.Count; i++)
{
Control ctrl = gv_links_edit.Rows[i].Cells[0].FindControl("[your item name]");
DropDownList ddl= (DropDownList)ctrl;
ddl.SelectedValue="USA";
}
i use this code and i dont have any problem.
good luck
msma.
www.toolsfa.com
|
|
|
|
|
Solved, In case some one is having similar probs.
var lb = document.getElementById("FormView1_CmbCountry");
for(var i=0;i<lb.options.length;i++)
{
if(lb.options[i].text=sCountry)
{
lb.options[i].selected = sCountry;
}
}
Thanks for your reply....;)
Amit
|
|
|
|
|
This works ? It looks like javascript to me, and I thought the selected property could only be true or false ?
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 )
|
|
|
|
|
I try to use the dataRepeater to show a reapet data in a web page, the database is Sql
but unfortunatly i can't reach my point
please can someone help me (it's urgent)
Thank you very much
Assaf
|
|
|
|
|
Here[^] is an article that should at least get you started on what you're looking for (since you didn't post any code or an error you're receiving I'm not going to do much at this point)
Assaf82 wrote: please can someone help me (it's urgent)
Everyone's problem/question is "urgent", that doesn't makes your special so saying its urgent wont speed up the process.
"Well yes, it is an Integer, but it's a metrosexual Integer. For all we know, under all that hair gel it could be a Boolean."
Tom Welch
|
|
|
|
|
Well Tom I'm sorry
it's benifit, but can you tell me how to assaign the data to the element in the repeater
Thank you
Assaf
|
|
|
|
|
I try the code you give it to me but it give me th following error:
"The DataSourceID of 'Repeater1' must be the ID of a control of type IDataSource. A control with ID 'SqlDataSource1' could not be found."
What it's IDataSource type and how i can solve it
Thank in advance
Assaf
|
|
|
|
|
To assign vlaues in data repeater...
<%#DataBinder.Eval(Container.DataItem, "FirstName")%>
Thanks
Amit
|
|
|
|
|
"The DataSourceID of 'Repeater1' must be the ID of a control of type IDataSource. A control with ID 'SqlDataSource1' could not be found."
This message states it can't find the sqldatasource control you assigned to the repeater.
You could set the datasource in the code behind using a reader, dataset or custom business object as well. Otherwise, you will need to ensure you have the control on your page.
|
|
|
|
|
Please Someone can help me
i write this code but it didn't work cn someone tell here is the wrong :
Dim Conn As SqlConnection
Dim Query As String
Dim SqlComm As SqlCommand
Dim reader As SqlDataReader
Dim dt As New DataTable
dt.Columns.Add("FNAME")
Dim row As DataRow
Conn = New SqlConnection("Data Source=toshiba-owner;Initial Catalog=HRDataBase;Integrated Security=True")
Query = "SELECT fName,lName FROM Employee WHERE (EmployeeNum = 1243)"
SqlComm = New SqlCommand(Query, Conn)
Conn.Open()
reader = SqlComm.ExecuteReader
row = dt.NewRow
While reader.Read
row("fName") = reader.GetValue(0)
row("lName") = reader.GetValue(1)
dt.Rows.Add(row)
End While
myRepeater.DataSource = dt
myRepeater.DataBind()
Conn.Close()
and this error still appear:
"The DataSourceID of 'Repeater1' must be the ID of a control of type IDataSource. A control with ID 'SqlDataSource1' could not be found"
Thanks in advance
Assaf
|
|
|
|
|
what is on your aspx page? Typically that is an error caused by wrongly assinging the datasource control to an object like a repeater (usually on the UI side).
Outside of this, you only add one column to your data table, yet try to fill two columns from a data reader.
Check the aspx page and the properties delcared for the repeater control. More than likely you will find the error.
|
|
|
|
|
|
If your using the load control method, you do not need to add anything to the top of your page.
You should be able to modify your code like so(VB):
Dim ctrl As UserControl = CType(LoadControl("~/MyControl.ascx"), UserControl)
I think this is the C# conversion:
UserControl ctrl = (UserControl)LoadControl("~/MyControl.ascx");
|
|
|
|
|
You got my 5!!!!
Such a simple solution and yet nowhere to be found!!
Thanks and have a great day.
Alberto Bar-Noy
Project Manager
http://www.consist.co.il
|
|
|
|
|
|
Hi,
I am trying to set the background of a partcular day of a calender (the asp:Calendar control) as follows:
e.Cell.BackColor = System.Drawing.Color.Aqua;
How do I set the back color to something like #FF0000? Or #CECECE?
Please can someone help?
Regards
ma se
|
|
|
|
|
Use ColorTranslator class:
Color c = ColorTranslator.FromHtml("#CECECE");
|
|
|
|
|
ma se wrote: How do I set the back color to something like #FF0000?
e.Cell.BackColor = System.Drawing.FromArgb(0xFF, 0x00, 0x00);
ma se wrote: Or #CECECE?
e.Cell.BackColor = System.Drawing.FromArgb(0xCE, 0xCE, 0xCE);
---
single minded; short sighted; long gone;
|
|
|
|
|
I have an ASP.NET web application that needs to retrieve an assembly name from a database and then call the appropriate assembly when a page loads. For example, I have a function in an assembly such as MyCompany.MyFunction() and a function/assembly of CustomCompany.MyFunction(). Is the InvokeMember() the best method?
Thanks
|
|
|
|
|
You can create the class instance using activator class.
Check the documentation at msdn[^]
|
|
|
|
|
I'm trying to wrap ASP.net access around a classic ASP site. The reasons aren't important, and I can't refactor the site into .Net (it's not funded and I've been expressly told not to do it). So I a the .Net stuff written, but when I try to run the website from within VS2005, I get the following error message:
<br />
<big>This type of page is not served.</big><br />
<br />
Description: The type of page you have requested is not served because it has been explicitly forbidden. The extension '.asp' may be incorrect. Please review the URL below and make sure that it is spelled correctly. <br />
<br />
Requested URL: /mysite/CACLogin/SiteMain/myfile.asp<br />
It seems that the internal web server in VS2005 does not allow classic ASP pages to be served. Is there a way to turn this restriction off?
I don't have IIS installed on my system, and I don't want to install it. I want to be able to run the whole site from within VS2005.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|