|
Directory.GetLogicalDrives()
|
|
|
|
|
Hi,
I am adding one user control(Login.ascx) to my web form’s Placeholder Control in a button click event of the (Home.aspx) page.
When ever i am clicking on the webform button i can able to add the user control to the Placeholder. but the problem is when ever i am trying to click on the User Controls Button its disappearing from the form. Even though I checked the view state also. When i am loading the User Control to the Placeholder it is firing the PageLoade Event of the User Control (Login.ascx).I want the User Control has to be appear in then form and also the ButtonClick event of the User Controls is to fire, so how to make this work. if any one have the solution for it please help me
Code:
Login.ascx
Button2_Click
{
Response.Wrie("Test");
}
Home.aspx
Button1_Click
{
UserControl MyControl = (UserControl) LoadeControl("Login.ascx");
//User Control(Login.ascx) is residing in the same folder
PlaceHolder1.Control.Add(MyControl);
// Its firing the Page Loade event of the User Control (Login.ascx)
}
sri
|
|
|
|
|
So, you are adding the UC dynamically?
|
|
|
|
|
Yes i am adding UC at run time
sri
|
|
|
|
|
Then you have to rewire the events on every postback.
|
|
|
|
|
Hi ALl
I have one datagrid in asp.net.I have two columns which are added runtime not a boundcolumn.
I add one button in one of the cell of datagrid in itemdatabound event.
like dim btn as new button
e.item.cell(0).controls.add(btn)
but when I click on that button,no event is fired.
I want to know which event is fired when i click on runtime button of datagrid?
Thanks
monika
|
|
|
|
|
I think you have to add a server control to your datagrid.
<td><asp:Datagrid CommandName="ID"
Text=<%# DataBinder.Eval(Container.DataItem, "au_id") %>
runat=server/></td>
The above line will add a Button control within the Datagrid control. The CommandName property is used to uniquely identify the button; if there is more than one Button control, each control must have a different CommandName.
Next, we need to modify the <asp:Datagrid> element so that it knows which event to fire when the Button control is clicked. We need to specify the OnItemCommand property, indicating the event to service when the button is clicked:
<asp:Datagrid id="Datagrid1"
OnItemCommand="Button_ItemCommand" runat="server">
Lastly, code the routine for the Button_ItemCommand event:
Sub Button_ItemCommand(ByVal Sender As Object, _
ByVal e As DatagridCommandEventArgs)
If e.CommandName = "ID" Then
Response.Write("ID selected is " & _
CType(e.CommandSource, Button).Text())
End If
End Sub
Hope this may help u
Regards,
Suresh Dayma
Everything Is Possible!
|
|
|
|
|
Hi
Thanks for your kind response , but you didn't get mt question.
i add one button in ItemdatBound event of datagrid.i give a command name to that button but itemcommand event not fired .
eg. dim btn as new button
e.item.cell(0).control.add(btn)
btn.commandname="edit"
how to create runtime button in itemcreate event of datagrid ?
and is it possible to fire itemcommand event when i clicked tht added button ?If is it possible give us example.
Thanks in advance ,
Monika
|
|
|
|
|
|
Hi there...
I want to count the total records which retrieving from database. By using DataReader, how can i count the records and i store that in a textbox..
Regards n Thanks
Sam.M
|
|
|
|
|
Datareader fetches one row at a time as so you need to loop thru while end of Datareader (read) and increment an explicit counter variable to count the records.
Mubashir
Every job is a self portrait of the person who did it.
|
|
|
|
|
Hi ....
Very thks... but i want to get the total number of records using datareader
Thks n Advance
Sam.M
|
|
|
|
|
As far as i am concerned....this is not possible.......you need to loop thru with DataReader to get the count.......OR use datasets
Mubashir
Every job is a self portrait of the person who did it.
|
|
|
|
|
Try this code
dim i as integer=0
do while dr.read()
i=i+1
loop
Label1.Text="No of Records : " & i.toString()
Hope this may help u
Regards,
Suresh Dayma
Everything Is Possible!
|
|
|
|
|
The datareader is a secuencial reader.
so you must to loop all the datareader to know how many files you got.
<br />
sqldatareader dr = sqlcommand.executereader();<br />
<br />
int num_lines = 0;<br />
while dr.read()<br />
{<br />
i++;<br />
}<br />
<br />
Message.Text = i.toString();<br />
Have Fun
keep Learning and you never will be out of date...
|
|
|
|
|
Sam.M wrote: I want to count the total records which retrieving from database. By using DataReader, how can i count the records and i store that in a textbox..
You can't directly. DataReader classes read through a file sequential, so you'd have to read all records and increment your own counter.
Depending on how many records, you could load the data into a DataSet/DataTable and use the Rows.Count to find out how many rows.
Alternatively, run a SELECT Count(*) on your table and return that result via a DataReader.
|
|
|
|
|
|
foreach(DataGridItem dataGridItem in DataGrid1.Items)
{
string r=(dataGridItem.Cells[2].Text);
Int32 sum=int.Parse(r);
Response.Write(sum);
}
iam using the above code and iam trying to convert an
string to int iam getting exception
Input string was not in a correct format. at System.Number.ParseInt32(String s,NumberStyles style, NumberFormatInfo info)
plz let me know asap
with regards
ravi
|
|
|
|
|
What string are you getting in variable 'r' ?
Mubashir
Every job is a self portrait of the person who did it.
|
|
|
|
|
|
What is the value you are getting in r(string)? It may not be a integer thats why you are getting the exception.
Best Regards,
Apurva Kaushal
|
|
|
|
|
This code may help u
// C# code
String sNumber = "123";
int iNumber = Convert.ToInt32(sNumber);
' VB.NET code
Dim sNumber as String = "123"
Dim iNumber as Integer = Convert.ToInt32(sNumber)
Thanks and regards,
Suresh Dayma
Everything Is Possible!
|
|
|
|
|
How can i stop back button(disable) when my home page is loaded or when user logout. so how can i trace back button.
provide code to trap back button.
Deepak
Smile a Lots,Its Costs Nothing
|
|
|
|
|
i can give you a idea.
when a user is logoff you application that time you have to call a another form (like "logout.aspx" )for stoping in to user go back.
now you can write a javascript on Body tag window.open(index.aspx");
wirte in Header Tag
<code><javascript>
function logout()
{
window.open(index.aspx");
}
</javascript></code>
call this function on body load.
<big><b><body onload="logout()"></b></big>
i thing this is very help full for you.!
Cheer
Pavan Pareta
|
|
|
|
|
Hi All
I need to generate multiple line charts dynamically using ADO.NET data in ASP.NET 1.1 application.
If anyone can provide me a link to some example code to handle line charts. By "line
graphs" means,graphs that have dates on the X-axis and data on the Y-axis in several colored lines .
I'm limited of not using any readily available graph tools/controls.
The Graph with features i'm looking to generate will look in the manner as available in this link below:
(http://finance.yahoo.com/charts) or (http://finance.google.com/finance?q=CSCO)
Thanks in advance
Regards-
bskvarma
|
|
|
|