|
Well, If you know the index of Peach , just set the SelectedIndex property.
ddlfruits.SelectedIndex = PeachIndex If not, iterate through each item, check the text is Peach , if yes make it selected.
ddlfruits.SelectedIndex = -1;
foreach (ListItem item in ddlfruits.Items)
{
if (item.Text == "Peach")
item.Selected = true;
}
|
|
|
|
|
|
|
Do they have examples ? Do they have forums ? There's a small number of peopel who are very active in this forum, and how do you know any of us even use this library ?
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
I have button which opens the dialog box to select a filename. the filename with path i am storing in textbox.
when i click on the button , i want to create one hyperlink and set its text and navigateurl property to textbox1.text.
i can able to create one hyperlink. but i want to create as many hyperlinks as button clicked by the user and textbox is not blank.
my code on button click event is
Dim HyperLink As HyperLink = Nothing
HyperLink = New HyperLink()
HyperLink.ID = "HyperLink" & i
HyperLink.Text = TextBox1.Text
HyperLink.NavigateUrl = "file:///" & TextBox1.Text
PlaceHolder1.Controls.Add(HyperLink)
PlaceHolder1.Controls.Add(New LiteralControl(" "))
This is working for one hyperlink , when i click on 2nd time button , the text changes to textbox1.text but it deletes the 1st hyperlink.
i tried Me.Controls.Add(New LiteralControl("<a href = " + HyperLink.NavigateUrl + ">" + TextBox1.Text + "</a>"))
but its not working.
Please help me as i am stuck here since one week. i dont know how to get rid of this problem.
i tried with ajaxextension, but i dont know how to use it.
one more thing i dont want to upload , i just want to attach this file to email. and if user wants to see this file he can click on hyperlink and he/she can open from the page and they can see the list of files that they have selected for the attachment.
Please help...with the code.
Thanks in advance.
Hemrk.
|
|
|
|
|
Does it post back to create the hyperlink ? THe postback is losing the dynamically created control because, well, it doesn't get recreated during te postback. You need to store the details of all the controls you created in viewstate so that on postback you recreate them all. Actually, you can just create links with javascript, if you know the URLs, from the textbox. No postback or AJAX needed.
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
I have solved the problem using viewstate. so i didnt use any updatepanel and ajaxtoolkit stuff. it was so simple with viewstate.
|
|
|
|
|
Ok, first off, I am new to this and need a little help. I am trying to have an external web page open in a ContentArea of a ASPX page. I am using Master Pages for my web design, and I don't know how to have the external page (from another site) open in the content area. Please help.
Here is the code I have so far:
<asp:content id="Content1" contentplaceholderid="maincontent" runat="Server" xmlns:asp="#unknown">
|
|
|
|
|
Directly you can't open external page on a content place holder. Put an HTML IFrame in the content page and load the external page to there.
|
|
|
|
|
I have a GridView, which is associated with a sqldatasource.
Not every values retrived by the sqldatasource from the database table is displayed in the grid view.
From the code-behind (.aspx.cs), i want to access this data for every row and decide whether a button present in that row shall be visible/invisible.
Please help ...
Apurv
|
|
|
|
|
You can handle gridview's databind events like RowDataBound . You will get access to current row.
|
|
|
|
|
Thanks ....
its done ...
Apurv
|
|
|
|
|
I have a gridveiw that there is a button in every row of it.I want to when I click the button ,the item that is in a this row add to my shoppingcart.what code should I write for my gridview.
|
|
|
|
|
Write code for the click event of the button
When you bind the gridview, bind the CommandArgument of the button to the ID of the product of the corresponding row
In the code for the click event check the commandargument of the sender (the button) and do what you got to do to add the item to shopping cart
Alexei Rodriguez
|
|
|
|
|
hai all,
i want to display 'P' instead of date in single line in grid view.
Here P means Present.
i have 2 table named as employee details and attendance.
emp_id and emp_name are the 2 field names for employee details table.
emp_id and date1 are the 2 field names for attendance table.
values in attendance table are
emp_id--------date1
---11---------10-08-2008
---11---------11-08-2008
---11---------12-08-2008
here datatype is datetime for date1 field.
in attendance table, the date values (10-08-2008,11-08-2008,12-08-2008) are present date for emp_id 11.
in output side,i select employeename as ajay from employeenamedropdownlist,then i select fromdate as 09-08-2008,then i select todate as 13-08-2008,then i finally click submit button.
when i click submit button,the following output coming in grid view using my program
EmployeeID--EmployeeName--09-08-2008--10-08-2008--11-08-2008--12-08-2008--13-08-2008
---11--------------------Ajay------------------------------10-08-2008
---11--------------------Ajay------------------------------------------------11-08-2008
---11--------------------Ajay-------------------------------------------------------------------12-08-2008
but this output is wrong.
here 2 mistake.
1st mistake:
instead of 'P',displaying date in 3 lines.
P means Present.
2nd mistake:
Displaying 3 lines for same employeeid and employeename.
so i want to display 'P' instead of date in single line in grid view as follow
EmployeeID-----EmployeeName-----09-08-2008-----10-08-2008-----11-08-2008-----12-08-2008-----13-08-2008
---11-------------------Ajay-------------------------------------------P-------------------P--------------------P
how to do this?
here my program using C# in asp.net
protected void SubmitButton_Click(object sender, ImageClickEventArgs e)
{
from_date = fromdatetextbox.Text;
to_date = todatetextbox.Text;
emp_name = employeenamedropdownlist.SelectedValue;
check();
}
void check()
{
System.TimeSpan dt_diff = Convert.ToDateTime(to_date).Subtract(Convert.ToDateTime(from_date));
days = dt_diff.Days;
for (int i = 0; i <= days; i++)
{
sql_date = Convert.ToDateTime(from_date).AddDays(i).ToString("MM/dd/yyyy");
da = new SqlDataAdapter("select distinct a.emp_id as EmployeeID,a.emp_name as EmployeeName,min(case when b.date1='" + sql_date + "' then b.date1 end) as '" + sql_date + "' from employeedetails as a,attendance as b where a.emp_id=b.emp_id and b.date1='" + sql_date + "' group by a.emp_id,a.emp_name", con);
da.Fill(dt);
}
GV_musterrole.DataSource = new DataView(dt);
GV_musterrole.DataBind();
}
any other program(C# or VB.net) or any other logic or any other way is there.
|
|
|
|
|
Hi
I am trying to select distinct fields from a table.
The problem is some of them are still duplicating even with the distinct function there.
Why would this be?
Does the distinct function not work with every query?
|
|
|
|
|
First this is not a SQL Forum.
.netman wrote: The problem is some of them are still duplicating even with the distinct function there.
Why would this be?
Second you didn't provide your query.
.netman wrote: Does the distinct function not work with every query?
It does. Definitely, there is some problem with your query or the way you are expecting the result.
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
I needed to use group by clause which then helped eradicate the problem.
|
|
|
|
|
u r right, this happens ...
u may try to use WHERE clause (if possible)...
Apurv
|
|
|
|
|
Please provide the query.
|
|
|
|
|
Problem/error message :
System.Web.HttpException: The GridView 'gv' fired event RowEditing which wasn't handled.
how i solve this problem while all things work properly like add, delete. but when i click on edit button its not work given error which i mention up.
I will do my best?
|
|
|
|
|
(in general this will happen when you want to add a code for any gui element)
in .net whenever you double click on any button, it will generate two entries, first it will register an event handler, and secondly it will create an empty function for you to code which will execute when that button clicked.
(your problem)
now here you have once created the function for that grid view and then after you have deleted that function, but the event registration is still there so when you run the code it will fire the event but there is no function code to execute. so just click on that gridview then go to properties and then click on a small tab for event. there will be an entry for that function just remove that and it will not show you the error.
Hope this will help...
|
|
|
|
|
i have a paragraph/article in database for example
abcdefghij aaaaaaa bbbbbbbbbb ccccccc dddddddd eeeeeee fffffff
i just want to show some beginning text from that paragraph/article in my asp.net page when user click details then it show the whole paragraph or article
HOW TO PICK STARTING TEXT FROM DATABASE ONLY abcdefghij NOT THE WHOLE ARTICLE?
|
|
|
|
|
First dont type in capitals it means you are shouting.
To cut of the text surely just set the character limit on the field when you take it from the database
|
|
|
|
|
you can use substring in your sql statement / C# code.
i.e.
SQL : select substring(para,1,10) from mytable where paraID = 1234
C# : short_para = para.Substring(0,10);
also just check the lenght > 10 of the string before this so that you will not get the error like. index is out of the string...or something...
and please (dont take this in wrong way) first try the google or msdn, if you dont get the answers then post in the forum. because there are soo many post in the different forums, for the indian developer posting basic questions (questions that can be found using google ot msdn). (I just read one in the Lounge)
may be this is the reason nobody is replying you, or i may also get a reply that dont answer such basic questions.
there is one article on code project for how use google search. please refer to that.
thanks...
|
|
|
|