|
In page load add
button1.Attributes.Add("onclick","javascript:DisButton('" & button2.ClientID & "')")
JS Function
function DisButton(cntrl)
{
document.getElementById(cntrl).disabled=true;
return false;
}
on button1 click button2 will disable.
EVEN THE WORD IMPOSSIBLE SAYS I M POSSIBLE.
|
|
|
|
|
thanks for Reply.
but i have to access control id from javascript.
like we access another control value.
also button on which i have to access javascript is outside the repeater.
and i required control id which is in repeater.
can u help me in this regards
thanks
|
|
|
|
|
I'm not sure what you are trying to do.
You have repeater and that contains a button atleast. say button1
You have an another button thats outside the repeater. say button2
So on button2 click you want to disable the button1.
If this is the requirement....
1.You can use the FindControl function of repeater to get controls inside therepeater, and pass the ID of button1 to the JS function.
2.You can store the ID inside a hidden field and get it in the JS.
Hop this Helps you...
EVEN THE WORD IMPOSSIBLE SAYS I M POSSIBLE.
|
|
|
|
|
Hi
I have the following code which should count the number of rows in the gridview ands then I want it to assign a number to it, so if there three rows it would assing 1, 2, 3 to each row but its not working it shows error Cannot implicitly convert type 'int' to 'string'
any help would be great!
for (int x = 0; x < GridView1.Rows.Count; x++)
{
GridViewRow row = GridView1.Rows[x];
dropdown = ((DropDownList)row.FindControl("ddorder"));
int count =+ 1;
dropdown.DataValueField = count;
}
|
|
|
|
|
Your Code
for (int x = 0; x < GridView1.Rows.Count; x++)
{
GridViewRow row = GridView1.Rows[x];
dropdown = ((DropDownList)row.FindControl("ddorder"));
int count =+ 1;
dropdown.DataValueField = count;
}
Tip:
Or the control does not exist
or it should be count.ToString();
Int32 count = 0;
DropDownList dropdown = new DropDownList();
foreach (GridViewRow row in GridView1.Rows)
{
try
{
dropdown = ((DropDownList)row.FindControl("ddorder"));
count++;
dropdown.DataValueField = count.ToString();
}
catch (Exception err)
{
}
}
Good Luck
|
|
|
|
|
I tried your code and it showed blank in the dropdownlist:
why would this be?
thhanks"
|
|
|
|
|
You only fill DataValueField but you should also fill DataTextField.
In the OnSelectedIndexChanged- event you can then pick the .SelectedValue, which is the DataValueField.. If you pick in that event the .SelectedIndex.Text you have the DataTextField.
In this case you can show a database description field in the DataTextField while attaching it's databse field ID to the DataValueField.
|
|
|
|
|
OK thanks for that
Now say Ive got 3 rows I want to add 1,2,3 to each dropdown in each row therefore I want the number of rows to appear in the dropdownlist, how would I do that? WOuld it just be an extension to the code I have?
|
|
|
|
|
the extension would be like this.
DropDownList dropdown = new DropDownList();
foreach (GridViewRow row in GridView1.Rows)
{
try
{
dropdown = ((DropDownList)row.FindControl("ddorder"));
for (int count = 1; count <= 3; count++)
{
dropdown.Items.Add(new ListItem(count.ToString(),count.ToString()));
}
}
catch (Exception err)
{
}
}
|
|
|
|
|
OK, final question
How do I select the correct row dropdownlist when updating my database.
At the moment when I set it to dropdown.selecteditemvalue it takes the very last row value instead of the current one.
How would I fix this?
thanks for your great help so far!
also how do I get another column value from the same row?
|
|
|
|
|
DropDown.SelectedValue I guess you mean
You know you hav to run along each GridViewRow to see the value of the dropdown control?
Like i showed you
Int32 selectRow = 0;
foreach (GridViewRow row in GridView1.Rows)
{
GridView1.SelectedIndex = selectRow;
// find you dropdownControl
//row.SelectedValue will show now values
selectRow++;
}
|
|
|
|
|
digimanus wrote: dropdown.Items.Add(new ListItem(count.ToString(),count.ToString()));
There is no reason to set the text and the value to the same value. A ListItem without a value returns the text property as value.
dropdown.Items.Add(new ListItem(count.ToString()));
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
I did not know this. Thanks for the tip
|
|
|
|
|
Well....If you want to add an item to the DropDownList you could do
dropdown.Items.Add(new ListItem(count.ToString(),count.ToString()));
in stead of dropdown.DataValueField = count.ToString();
dropdown.DataTextField = count.ToString();
DataxxxxField is used for DataBinding for values retrieved from a database
In page_Load remember to place code in
if (!Page.IsPostBack)
{
// the code
}
modified on Thursday, July 10, 2008 9:37 AM
|
|
|
|
|
|
|
Thanks for replying. I used that too but it has same problem. Please help me.
DAsh04
|
|
|
|
|
I would try this
protected void CheckLogin()
{
if (Session["LoginAdminUser"] == null)
{
Response.Redirect("~/admin/oola_log_in.aspx");
}
else
{
LoginUser= Session["oLoginAdminUser"].ToString(); }
}
LoginUser = Type String
Session["oLoginAdminUser"] = Type Object so you need the ToString() addition
|
|
|
|
|
no not solved still
DAsh04
|
|
|
|
|
i want to use this code in asp
VBA.Calendar = vbCalHijri
date
|
|
|
|
|
Hello everybody,
I am facing a problem. I am trying to upload a file using Pure ASP and I am not using any component. On development server it is allowing upto 10MB to upload but on production server it is not taking more than 1KB. If I try to upload more than 1KB file "Internal Server Error" page is getting displayed.
Thanks
Intelligence is measured by common sense not by how many scholarly books you read.
|
|
|
|
|
Hi,
In web.config <system.web>, add the following code
<system.web>
<httpruntime maxrequestlength="1024000" />
//Here u can give ur maximum size of the file.
</system.web>
Sutheesh Ramachandran
Cybernet Software Systems,
T Nagar, Chennai 17.
|
|
|
|
|
Thanks for the reply but it is not ASP.NET application rather it is Pure/Classic ASP application.
Intelligence is measured by common sense not by how many scholarly books you read.
|
|
|
|
|
This is an asp.net forum, So you could ask better your question in an asp forum
EVEN THE WORD IMPOSSIBLE SAYS I M POSSIBLE.
|
|
|
|
|
Hi
I have gridview with a values in as well as a dropdownlist
When I click on the dropdownlist to choose a value I need this value to then be updated to the database.
My question is how can I find the id of the current row I am on so that the correct record is updated?
any help on this would be great thanks!
|
|
|
|