|
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...
|
|
|
|
|
I am reading some data from the database, but its giving System.InvalidOperationException:
my code is as follows :
LoadInfo l = new LoadInfo();
l.LoadFromSQL(Session["username"].ToString());
the class LoadInfo has the member function LoadFromSQL as follows,
public void LoadFromSQL(string username)
{
SqlDataReader reader = null;
reader = SqlMember.ExecuteReader("SELECT UserId FROM Members WHERE UserName=@username", username);
m.LoadFromReader(reader);
}
the SqlMember class has the static member function ExecuteReader as following:
static public SqlDataReader ExecuteReader(string qs,string username)
{
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
SqlCommand cmd = new SqlCommand(qs, conn);
cmd.Parameters.Add(new SqlParameter ("@username","a"));
conn.Open();
if (cmd.ExecuteScalar() == null)
{
int i;
i = 0;
}
return cmd.ExecuteReader();
}
the LoadFromReader member function of SqlMember class is as follows:
public void LoadFromReader(SqlDataReader reader)
{
this.UserId = (int)reader["UserId"];
this.FirstName = (string)reader["FirstName"];
this.LastName = (string)reader["LastName"];
this.CityId = (int)reader["CityId"];
this.CountryId = (int)reader["CountryId"];
this.Mood = (byte)reader["Mood"];
}
The exception is occurring in the above function, while reading the data from the reader
this.UserId = (int)reader["UserId"];
if this line is commented (//) the exception occurs in the next line.
Error:
Invalid attempt to read when no data is present.
The username provided by the session object is available in the database.
Please help me to solve this problem.
Is there any way to know, if the ExecuteReader returned any values ?
Apurv
|
|
|
|
|
I think it is showing you the error because you forgot to call Read()
also your query returns only UserID and you are reading whole row.
so change the
Select UserID FROM Members WHERE UserName=@username to
Select UserID,FirstName,LastName,CityId,CountryId,Mood FROM Members WHERE UserName=@username
in the LoadFromReader()
public void LoadFromReader(SqlDataReader reader)
{
if(reader.Read())
{
this.UserId = (int)reader["UserId"];
this.FirstName = (string)reader["FirstName"];
this.LastName = (string)reader["LastName"];
this.CityId = (int)reader["CityId"];
this.CountryId = (int)reader["CountryId"];
this.Mood = (byte)reader["Mood"];
}
else
}
also change the ExecuteScalar() to ExecuteReader()
because now you are getting more than one values.
|
|
|
|
|
thanx ....
will try with the changes ...
Apurv
|
|
|
|
|
Its working thanks .....
Apurv
|
|
|
|
|
Hi All,
I am developing a WebApplication using ASP.NET and C#.
there is a exception occurs when i call for a XmlWeb Service --Web Method.
This is the code.
try{
DataXML service=new DataXML();
service.Timeout = 10 * 60 * 1000;
object[] results = service.GetProductionData();
}catch(Exception ex)
{
str=ex.Message;
}
Here we have to wait around 100 seconds to get the response. But before that there is exception occurs and the error message says
'The underlying connection was closed: The connection was closed unexpectedly
So the client side returns a exception before results come. why is that??
can any one help on this?
Thanks in advance..
|
|
|
|