|
Hi All,
I am using StoreProcedure to delete Row .I have passed Parameter GroupId to StoreProcedure ,to delete row.I am using Datasource to bind data in data grid .I want to delete Row from GridView ,onClick of Delete. But What is happening is,When i click on select then I need to click on Delete and It gets delete. I want to delete On click of delete.
Help me Plz.
Pallav
|
|
|
|
|
Place a delete button in the gridview and then on click of that button call the stored procedure to delete the row. And after deleting the row bind the gridview again.
Apurva Kaushal
|
|
|
|
|
|
Always welcome..
Apurva Kaushal
|
|
|
|
|
The first Question About "App_GlobalResources" , I did according to the teaching material, but can't display fi-FI, only display English. Thanks for your help. The following is original text:
\App_GlobalResources Folder
Resource files are string tables that can serve as data dictionaries for your applications when these applications require changes to content based on things such as changes in culture. You can add Assembly Resource Files (.resx) to this folder, and they are dynamically compiled and made part of the solution for use by all your .aspx pages in the application. When using ASP.NET 1.0/1.1, you had to use the resgen.exe tool and also had to compile your resource files to a .dll or .exe for use within your solution. Now it is considerably easier to deal with resource files in ASP.NET 2.0.
In addition to strings, you can also add images and other files to your resource files. For an example of how to use resource files to create a multilingual ASP.NET 2.0 application, first create the \App_GlobalResources folder in your application. For this example, create two resource files in this folder: Resource.resx and Resource.fi-FI.resx. The first file, Resource.resx, is the default language file using American English. The second file is for the same text, but in the Finnish language. Hence, this file uses fi-FI in its name. When someone with a browser culture of fi-FI invokes the page, he sees the information that comes from this file (Resource.fi-FI.resx). Everyone else who comes to the site gets the information that comes from the other file (Resource.resx).
Notice (as shown in Figure 3-11) that you can actually do a lot with .resx files. The idea is to create a table of the items to be localized (such as text, images, and files). For this example, you can stick to text.
Figure 3-11:
The Resource.resx file should have the following structure:
Name Value
Answer Hello there
PageTitle Sample Page
Question What is your name?
For the Resource.fi-FI.resx file, use the following structure:
Name Value
Answer Hei
PageTitle Näytesivu
Question Mikä sinun nimi on?
To use these files, create a simple .aspx page with the code from Listing 3-18.
Listing 3-18: A simple ASP.NET page that uses resource files
VB
<%@ Page Language= "VB " Culture= "Auto " UICulture= "Auto " %>
Protected Sub Page_Load(ByVal sender As Object, _
ByVal e As System.EventArgs)
Page.Title = Resources.Resource.PageTitle
End Sub
Protected Sub Button1_Click(ByVal sender As Object, _
ByVal e As System.EventArgs)
Label1.Text = Resources.Resource.Answer & " " & Textbox1.Text
End Sub
<title>
<%= Resources.Resource.Question %>
<asp:textbox id="Textbox1 " runat="server ">
<asp:button id="Button1 " runat="server " text="Submit "
="" onclick="Button1_Click ">
<asp:label id="Label1 " runat="server ">
C#
<%@ Page Language= "C# " Culture= "Auto " UICulture= "Auto " %>
protected void Page_Load(object sender, System.EventArgs e)
{
Page.Title = Resources.Resource.PageTitle;
}
protected void Button1_Click(object sender, System.EventArgs e)
{
Label1.Text = Resources.Resource.Answer + " " + Textbox1.Text;
}
When this is run, you get the appropriate text based upon the culture setting in your browser. If this setting is not fi-FI, you get the American English text. The page output is shown in Figure 3-12.
Figure 3-12:
In order to see the Finnish text, change your preferred culture in the Microsoft Internet Explorer browser by choosing Tools ® Internet Options. This pulls up the Internet Options dialog. From the first tab, General, you can click the Languages button to pull up a dialog that enables you to specify the Finnish language as your preferred language choice. After you have added the Finnish language to the list, be sure that it is the uppermost choice in the dialog. You can do this by highlighting this choice and pressing the Move Up button until it is the uppermost choice.
After this is in place, run the page. You see the Finnish language output shown in Figure 3-13.
Figure 3-13:
The second Question About "callback" , I did according to the teaching material, but when I click the button, IE display an error, prompt the mothed "UseCallback();" has some error. Thanks for your help. The following is original text:
Using the Callback Feature — A Simple Approach
Begin examining the callback feature by looking at how a simple ASP.NET page uses it. For this example, you have only an HTML button control and a TextBox server control (the Web server control version). The idea is that when the end user clicks the button on the form, the callback service is initiated and a random number is populated into the text box. Listing 4-14 shows an example of this in action.
Listing 4-14: Using the callback feature to populate a random value to a Web page
.aspx page (VB version)
<%@ Page Language= "VB " AutoEventWireup= "false " CodeFile= "RandomNumber.aspx.vb "
Inherits= "RandomNumber " %>
<title> Callback Page
function GetNumber(){
UseCallback();
}
function GetRandomNumberFromServer(TextBox1, context){
document.forms[0].TextBox1.value = TextBox1;
}
<asp:textbox id="TextBox1 " runat="server ">
VB (code-behind)
Partial Class RandomNumber
Inherits System.Web.UI.Page
Implements System.Web.UI.ICallbackEventHandler
Dim _callbackResult As String = Nothing
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) _
Handles Me.Load
Dim cbReference As String = Page.ClientScript.GetCallbackEventReference(
Me, "arg ", "GetRandomNumberFromServer ", "context ")
Dim cbScript As String = "function UseCallback(arg, context) " & _
"{ " & cbReference & "; " & "} "
Page.ClientScript.RegisterClientScriptBlock(Me.GetType(), _
"UseCallback ", cbScript, True)
End Sub
Public Sub RaiseCallbackEvent(ByVal eventArgument As String) _
Implements System.Web.UI.ICallbackEventHandler.RaiseCallbackEvent
_callbackResult = Rnd().ToString()
End Function
Public Function GetCallbackResult() As String _
Implements System.Web.UI.ICallbackEventHandler.GetCallbackResult
Return _callbackResult
End Sub
End Class
C# (code-behind)
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class RandomNumber : System.Web.UI.Page,
System.Web.UI.ICallbackEventHandler
{
private string _callbackResult = null;
protected void Page_Load(object sender, EventArgs e)
{
string cbReference = Page.ClientScript.GetCallbackEventReference(this,
"arg ", "GetRandomNumberFromServer ", "context ");
string cbScript = "function UseCallback(arg, context) " +
"{ " + cbReference + "; " + "} ";
Page.ClientScript.RegisterClientScriptBlock(this.GetType(),
"UseCallback ", cbScript, true);
}
public void RaiseCallbackEvent(string eventArg)
{
Random rnd = new Random();
_callbackResult = rnd.Next().ToString();
}
public string GetCallbackResult()
{
return _callbackResult;
}
}
}
When this page is built and run in the browser, you get the results shown in Figure 4-15.
Figure 4-15:
Clicking the button on the page invokes the client callback capabilities of the page, and the page then makes an asynchronous request to the code behind of the same page. After getting a response from this part of the page, the client script takes the retrieved value and places it inside the text box — all without doing a page refresh!
Now take a look at the .aspx page, which simply contains an HTML button control and a TextBox server control. Notice that a standard HTML button control is used because a typical <asp:button> control does not work here. No worries. When you work with the HTML button control, just be sure to include an onclick event to point to the JavaScript function that initiates this entire process:
You don 't have to do anything else with the controls themselves. The final thing to include in the page is the client-side JavaScript functions to take care of the callback to the server-side functions. GetNumber() is the first JavaScript function that 's instantiated. It starts the entire process by calling the name of the client script handler that is defined in the page 's code behind. A string type result from GetNumber()is retrieved using the GetRandomNumberFromServer() function. GetRandomNumberFromServer() simply populates the string value retrieved and makes that the value of the Textbox control — specified by the value of the ID attribute of the server control (TextBox1):
function GetNumber(){
UseCallback();
}
function GetRandomNumberFromServer(TextBox1, context){
document.forms[0].TextBox1.value = TextBox1;
}
Now turn your attention to the code behind.
The Page class of the Web page implements the System.Web.UI.ICallbackEventHandler interface:
Partial Class RandomNumber
Inherits System.Web.UI.Page
Implements System.Web.UI.ICallbackEventHandler
' Code here
End Class
This interface requires you to implement a couple of methods—the RaiseCallbackEvent and the GetCallbackResult methods, both of which work with the client script request. RaiseCallbackEvent enables you to do the work of retrieving the value from the page, but the value can be only of type string:
Public Sub RaiseCallbackEvent(ByVal eventArgument As String) _
Implements System.Web.UI.ICallbackEventHandler.RaiseCallbackEvent
_callbackResult = Rnd().ToString()
End Sub
The GetCallbackResult is the method that actually grabs the returned value to be used:
Public Function GetCallbackResult() As String _
Implements System.Web.UI.ICallbackEventHandler.GetCallbackResult
Return _callbackResult
End Function
In addition, the Page_Load event includes the creation and placement of the client callback script manager (the function that will manage requests and responses) on the client:
Dim cbReference As String = Page.GetCallbackEventReference(Me, "arg ", _
"GetRandomNumberFromServer ", "context ")
Dim cbScript As String = "function UseCallback(arg, context) " & _
"{ " & cbReference & "; " & "} "
Page.ClientScript.RegisterClientScriptBlock(Me.GetType(), _
"UseCallback ", cbScript, True)
The function placed on the client for the callback capabilities is called UseCallback(). This string is then populated to the Web page itself using the Page.ClientScript.RegisterClientScripBlock that also puts tags around the function on the page. Make sure that the name you use here is the same name you use in the client-side JavaScript function presented earlier.
In the end, you have a page that refreshes content without refreshing the overall page. This opens the door to a whole new area of possibilities. One caveat is that the callback capabilities described here use XmlHTTP and, therefore, the client browser needs to support XmlHTTP (Microsoft 's Internet Explorer and FireFox do support this feature). Because of this, the .NET Framework 2.0 introduces the SupportsCallBack and the SupportsXmlHTTP properties. To ensure this support, you could put a check in the page 's code behind when the initial page is being generated. It might look similar to the following:
VB
If (Page.Request.Browser.SupportsXmlHTTP) Then
End If
C#
if (Page.Request.Browser.SupportsXmlHTTP == true) {
}
<div class="ForumSig">http://www.123de6.cn</div>
|
|
|
|
|
although the text is too long.
but the key code only a bit.
please notice the key code.
test your vs2005 compile it.
my english is poor. sorry.
http://www.123de6.cn
|
|
|
|
|
help
http://www.123de6.cn
|
|
|
|
|
Hai,
How to add a selected listbox data into another listbox
|
|
|
|
|
In Listbox you are having a Items.Add method using which you can add the selected items of the previous listbox.
Apurva Kaushal
|
|
|
|
|
Thanks for your co-operation i got the solution already.Sorry for the trouble made to you people.
|
|
|
|
|
That's alright..
Apurva Kaushal
|
|
|
|
|
Hi,
I'm facing one of the issue discussed in this article. I've created a user control with a DataGrid on it. I've created properties to make this control visible, and to set the connection information for database.
I'm doing all these in the Page_Load event of that user control. In the main form where i'm using this control, I have a button that I use to make this control visible. During Page load of main page, I make the user control visible false, and only when the user clicks the button its made visible.
But the problem is that before the button click event of the main form, the page_load of the user control is getting fired (as discussed in ur article).. What can I do now?
Regards,
Blumen
|
|
|
|
|
This is not an article, it's a programming forum. Page load is called before events. Always. Put it in your prerender, if you want it to fire after the button click.
There's a forum in the article, if you want to ask an author something
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Ok, I'll try it in Prerender event.
Sorry about the "article" reference in my message.
Regards,
Blumen
|
|
|
|
|
In my page there are two textboxes to enter dates. FromDate and ToDate textboxes. The difference between FromDate and ToDate should not be geater than 31 days. and also make sure FromDate should be less than ToDate. How to validate on client side. Am using asp.net 2.0 and c#.
Can anyone give solution?
Thanks in advance.
|
|
|
|
|
You can use calendar to avoid basic date validation. But if you are using simple text box to get the date then Here[^] you can get so much help.
Apurva Kaushal
|
|
|
|
|
Hello Guys.
This is just about my first post on here.
My problem on which i need some help on is as follows:
I have no problem invoking the edititemtemplate on a (Not nested) datalist.
But once i try invoking it on a nested datalist nothing happens, i have assured
that my edit button event fires. But the edititemtemplate never gets rendered.
Below you'll find a snippet of my aspx file:
<asp:DataList
ID="HeadlinesDataList"
runat="server"
OnItemDataBound="HeadlinesDataList_ItemDataBound"
DataKeyField="headlineID"
OnEditCommand="HeadlinesDataList_EditCommand"
OnCancelCommand="HeadlinesDataList_CancelCommand"
OnUpdateCommand="HeadlinesDataList_UpdateCommand">
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem, "headlineName") %>
<asp:LinkButton ID="EditHeadlineButton" runat="server" CommandName="Edit">[Edit]</asp:LinkButton><br />
!--Categories-->
<asp:DataList
ID="CategoriesDataList"
runat="server"
DataKeyField="categoryID"
OnEditCommand="CategoriesDataList_EditCommand">
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem, "CategoryName") %>
<asp:LinkButton ID="EditCategoryButton" runat="server" CommandName="Edit">[Edit]</asp:LinkButton><br />
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="CategoryName" runat="server" Text='<%# DataBinder.Eval Container.DataItem, "categoryName") %>'></asp:TextBox>
<asp:LinkButton ID="LinkButton2" runat="server" CommandName="Cancel">[Cancel]</asp:LinkButton>
<asp:LinkButton ID="LinkButton3" runat="server" CommandName="Update">[Update]</asp:LinkButton>
</EditItemTemplate>
</asp:DataList>
<!--/Categories-->
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="HeadLineName" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "headlineName") %>'></asp:TextBox>
<asp:LinkButton ID="LinkButton2" runat="server" CommandName="Cancel">[Cancel]</asp:LinkButton>
<asp:LinkButton ID="LinkButton3" runat="server" CommandName="Update">[Update]</asp:LinkButton>
</EditItemTemplate>
</asp:DataList>
<!--/Headlines-->
And here you'll see my code file for the aspx, My edit button on the nested datalist invokes this method:
CategoriesDataList_EditCommand
------------------------
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class showHeadlines : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
HeadLinesDatabind();
}
}
public void HeadLinesDatabind()
{
dbHeadlines myHeadlines = new dbHeadlines(ConfigurationManager.AppSettings.Get("ConnectionString"));
HeadlinesDataList.DataSource = myHeadlines.getheadlines(Request.QueryString.Get("structuretemplateid"));
HeadlinesDataList.DataBind();
}
public void CategoriesDatabind()
{
}
protected void HeadlinesDataList_ItemDataBound(object sender, DataListItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
dbCategories myCategories = new dbCategories( ConfigurationManager.AppSettings.Get("ConnectionString") );
System.Data.OleDb.OleDbDataReader myCategoriesReader = myCategories.getcategories(HeadlinesDataList.DataKeys[e.Item.ItemIndex].ToString());
((DataList)e.Item.FindControl("CategoriesDataList")).DataSource = myCategoriesReader;
((DataList)e.Item.FindControl("CategoriesDataList")).DataBind();
myCategoriesReader.Close();
}
}
protected void HeadlinesDataList_EditCommand(object source, DataListCommandEventArgs e)
{
//((DataList)source).EditItemIndex = e.Item.ItemIndex; // Works
HeadlinesDataList.EditItemIndex = e.Item.ItemIndex; // Works too
HeadLinesDatabind();
}
protected void CategoriesDataList_EditCommand(object source, DataListCommandEventArgs e)
{
// First attempt
DataList myCategoriesDatalist = (DataList)source; // Does not work
myCategoriesDatalist.EditItemIndex = e.Item.ItemIndex; // Does not work
// Second attempt
// ((DataList)source).EditItemIndex = e.Item.ItemIndex; // Does not work
// Third attempt
//((DataList)HeadlinesDataList.FindControl("CategoriesDataList")).EditItemIndex = e.Item.ItemIndex; // Does not work
HeadLinesDatabind();
}
protected void HeadlinesDataList_CancelCommand(object source, DataListCommandEventArgs e)
{
HeadlinesDataList.EditItemIndex = -1;
HeadLinesDatabind();
}
protected void HeadlinesDataList_UpdateCommand(object source, DataListCommandEventArgs e)
{
System.Web.UI.WebControls.TextBox HeadLineName = ((TextBox)e.Item.FindControl("HeadLineName"));
dbHeadlines myHeadlines = new dbHeadlines(ConfigurationManager.AppSettings.Get("ConnectionString"));
// myHeadlines.UpdateHeadlineName((int)HeadlinesDataList.DataKeys[e.Item.ItemIndex], ((TextBox)e.Item.FindControl("TextBox1")).Text);
myHeadlines.UpdateHeadlineName((int)HeadlinesDataList.DataKeys[e.Item.ItemIndex], HeadLineName.Text);
HeadLinesDatabind();
}
}
Okay i hope somebody can give me some help.. I'm just about to give up on this.
BTW: I'm coding in Visual Web Developer 2005 Express Edition.
Venlig hilsen / Regards
Steffen Otto Jensen
(Denmark)
|
|
|
|
|
Hi,
I need to call customized C# library serial on a local computer. How do i do it from asp.net pages? using C#.
I know how to call the dll if the dll is on the webserver. My dll access the usb device on the local pc.
Thanks
|
|
|
|
|
Nope. It is not possible to do that..
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
"Please vote to let me (and others) know if this answer helped you or not. A 5 vote tells people that your question has been answered successfully and that I've pitched it at just the right level. Thanks."
|
|
|
|
|
Hi,
ok here is the scenario:
I have two pages Transactions and Points. In the Transactions Page, I have an amount field. I was trying to pass on 10% of that amount to the Points page and directly set it in the Points Field.
I have tried several stuff. with some web help but it didn't work. I think what it is trying to do is open the page with a filter given the points= 10 example.
Please help
Thanks a lot
IssamK
|
|
|
|
|
how you are opening the Points page?
If you are opening it in a new window using javascript then you can pass it in querystring or you can access the field in transaction page using opener.document.getElementById(amountfield).
And if you are redirecting it from server side using response.redirect or server.transfer then you can keep it in session before redirecting and access it from session in Points page.
-----
|
|
|
|
|
|
Ok guys,
i am not very much aware of this code, i am just kinda debugging.
what is interesting to mention is this:
<smartone:themebutton runat="server" id="SaveButton" button-causesvalidation="True" button-commandname="UpdateData" <b="">Button-RedirectURL="Mypage.aspx?Points={TransactionRecordControl:FV:Amount}"
does it help?
thanks.
IssamK
|
|
|
|
|
here is the straight forward code.
in transaction.aspx add a button like:
<br />
<asp:button id="btn" runat="server" onclick="redirectToPoints" text="Open Points Page" /><br />
in code behind file for transaction.aspx.cs do this:
<br />
protected void redirectToPoints(object sender, EventArgs e)<br />
{<br />
Session["tranAmount"] = youramount;
Response.Redirect("points.aspx",true);<br />
}<br />
in PageLoad function in code behind file for points.aspx.cs do this:
<br />
protected void PageLoad(object sender, EventArgs e)<br />
{<br />
if(!IsPostBack)<br />
{<br />
textboxPoints.Text = Session["tranAmount"].ToString(); <br />
}<br />
}<br />
-----
|
|
|
|
|
hi friends,
am using one table,there is 3 field(name,address,father name) is having.but inserted totally 5 records.In all column data first character small letter.
example :(Database)
Name Address Father Name
raja salem rajasekar
laxman chennai anbuselvan
bala bangalore muthu
senthil covai durai
arun hosur ganesh
Note :
Am using front end repeater control.I want display all column data starting letter in capital letter.help me very urgent
I want display the front end form is example :
(FRONT END):
=============
Name Address Father Name
Raja Salem Rajasekar
Laxman Chennai Anbuselvan
Bala Bangalore Muthu
Senthil Covai Durai
Arun Hosur Ganesh
with Regards,
D.Thirumurugan.
|
|
|
|
|