|
I am trying to implement Insert, Edit, Delete feature in Grid View in ASP.NET 2.0 using GridView & ObjectDataSource.
'*********The GridView*******
<asp:GridView ID="GridViewCategories" Runat="server" DataSourceID="GoalCategorySource" DataKeyNames="CategoryID" OnRowCommand="GridViewCategories_RowCommand" ShowFooter="true">
'*****ObjectDataSource*******
The Grid View is bound to an ObjectDataSource below, where
GetCategories, UpdateCategory, DeleteCategory are methods of a .NET assembly, BizRules.GoalCategories
<asp:ObjectDataSource ID="GoalCategorySource" runat="server" TypeName="BizRules.GoalCategories" DataObjectTypeName="GoalCategoryEntity"
SelectMethod="GetCategories" UpdateMethod="UpdateCategory" DeleteMethod="DeleteCategory"
OnInserting="GoalCategorySource_Inserting" OnDeleting="GoalCategorySource_Deleting" OnUpdating="GoalCategorySource_Updating">
<InsertParameters>
<asp:Parameter Name="InsertCategoryName" Type="String">
<InsertParameters>
<UpdateParameters>
asp:Parameter Name="UpdateCategoryName" Type="String"
<UpdateParameters>
I was able to catch the Command Events from the GridView using GridViewCategories_RowCommand by using
protected void GridViewCategories_RowCommand(object sender, GridViewCommandEventArgs e)
{
switch (e.CommandName)
{
case "EditUpdate" :
Response.Write("Edit Update");
break;
case "EditCancel":
Response.Write("Edit Cancel");
break;
case "InsertNew":
Response.Write("Insert New");
break;
case "InsertUpdate":
Response.Write("Insert Update");
break;
case "InsertCancel":
Response.Write("Insert Cancel");
break;
case "Delete":
Response.Write("Delete");
break;
}
'*********Section of GridView***************8
<asp:TemplateField ShowHeader="false">
<<itemtemplate>>
<<asp:linkbutton id="lbEdit" runat="server" causesvalidation="False" commandname="Edit" text="Edit" >="">
<<asp:linkbutton id="lbDelete" runat="server" causesvalidation="False" commandname="Delete" text="Delete" >="">
<
<
|
|
|
|
|
hi guys i need help again =)
i am currently trying to make a form in a form
i a sure u guys seem microsoft access subform where by the subform is actually another form in the access and the user can navigate the form by those scroll bar even if the window of the form is small
i am trying to do that in vb.net! issit possible? if it is could anyone tell me which control/component to use and how to use it thx
|
|
|
|
|
What do you mean by a form in a form? You want to nest asp:Form tags? Can't be done. Do you want two section on the page with form fields and submit buttons? Thats not two forms, just controls in different places.
|
|
|
|
|
well i mean like i make 2 form ( from1 and form2)
how ever i would like to make a form viewer within form1 to view from 2
meaning: i would be able to view form2 thru a box(form viewer) while being in form1
wat i wanna know is that possible and if it is how? as i dont know if vb.net have such thing as form viewer >.< pls help!
|
|
|
|
|
|
well i mean like i make 2 form ( from1 and form2)
how ever i would like to make a form viewer within form1 to view from 2
meaning: i would be able to view form2 thru a box(form viewer) while being in form1
wat i wanna know is that possible and if it is how? as i dont know if vb.net have such thing as form viewer >.< pls help!
|
|
|
|
|
so i am guessing that it cant be done?
|
|
|
|
|
Hi,
I am uploading an image and replacing existing image. I have upload button that I am uploading the image with. How can I write code such that the uploaded image displays immediately.
If I use different file name for the image the file displays by setting up imageurl. However if I want to use the same file name as this image has to be displayed in other web application that runs on asp, the image does not load until I do a manual refresh of the page. It does not load even if I do a response.redirect to the same page. I believe it may be cache problem, if it is how to rectify it?
Raj D
|
|
|
|
|
It is by design. If you want to override you can avoid caching of the image thus incurring a performance overhead.
You can observe this syndrome in your CodeProject members page also.
|
|
|
|
|
Thanks Vasudevan,
How to avoid caching of the image, can you give code please..
Raj D
|
|
|
|
|
how to give DBO permissions to ASPNET_ tables that are created when I used the Login control supplied in visual studio. I created the tables on the SQL Server and pointing my login controls to those tables. But I get an error about DBO rights
please help
Raj D
|
|
|
|
|
hi
could anybody pls help how to write serial communication code in asp.net(asp) web application.
thanks in advance
|
|
|
|
|
|
Yes..but i'm not very sure with the code and..actually i can not find the control for serial port in visual web developer as MSComm control in visual basic 6
|
|
|
|
|
The Undo operation encountered a context that is different from what was applied in the corresponding Set operation. The possible cause is that a context was Set on the thread and not reverted(undone).
this error is comeing in my application plz help
|
|
|
|
|
How to call up current page using response.redirect or server.transfer? how to get current page into a variable to use with server.transfer?
Appreciate input
Raj D
|
|
|
|
|
If you want to call the current page then better use the following.
server.transfer(Request.CurrentExecutionFilePath);
Koushik
|
|
|
|
|
Hi,
I am studying this book "Microsoft Visual C# 2005 Step by Step (by John Sharp)". I used a piece of code written in the book and I get an error message. Could you please help me fix it?
==========================================
using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Configuration;
using System.Data.SqlClient;
using System.Diagnostics;
[WebService(Namespace = " http://www.contentmaster.com/WebSite3")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class Service : System.Web.Services.WebService
{
public Service () {
//Uncomment the following line if using designed components
//InitializeComponent();
}
[WebMethod]
public string HelloWorld() {
return "Hello World";
}
[WebMethod]
public decimal Howmuch(string name,int q)
{
SqlConnection sqlcon = null;
try
{
ConnectionStringSettings cs = ConfigurationManager.ConnectionStrings ["productconnstring"];
string connnstring = cs.ConnectionString;
sqlcon = new SqlConnection(connnstring);
SqlCommand sqlcomd = new SqlCommand();
sqlcomd.CommandText = "SELECT StandardCost FROM Production.Product" + "WHERE Name= '" + name + "'";
sqlcomd.Connection = sqlcon;
sqlcon.Open();
decimal price = (decimal)sqlcomd.ExecuteScalar();
return (price * q);
}
catch (Exception ex)
{
Handlewebexception(ex);
}
finally
{
if (sqlcon != null)
sqlcon.Close();
}
}
//Local private method to handle exceptions
private void Handlewebexception(Exception e)
{
EventLog log = new EventLog("Application");
log.Source = "website3";
log.WriteEntry(e.Message, EventLogEntryType.Error);
}
}
=======================================================
I use:
--- Windows XP Professional SP2
--- Visual Studio 2005
--- Microsoft SQL Server 2005
--- AdventureWorks Database
Error Message when I do "Build Website" - "Error 1 'Service.Howmuch(string, int)': not all code paths return a value C:\Documents and Settings\Srivathsan\My Documents\Visual Studio 2005\WebSites\WebSite3\App_Code\Service.cs 26 18 C:\...\WebSite3\ "
Please let me know how to fix it. I believe there is something wrong with return statements (absence of it somewhere). I am unable to figure out.
I would appreciate any suggestions,
Harni.
|
|
|
|
|
Hi,
howmuch function must retuen decimal value, you put return statment in try clause only, but you must put i also in finally clause in case any exception found
finally
{
if (sqlcon != null)
sqlcon.Close();
return 0;
}
I hope it work
|
|
|
|
|
harni.a wrote: catch (Exception ex)
{
Handlewebexception(ex);
}
What does this return?
|
|
|
|
|
private void handleWebException(Exception e)
{
EventLog log = new EventLog("Application");
log.Source = "WebSite3";
log.WriteEntry(e.Message, EventLogEntryType.Error);
}
Actually,this method displays the error description in a windows application event log.
Regards,
Harni Srivathsan.
|
|
|
|
|
Hi, I've made a very simple web service with a wizard. It was ok when I worked on it last week, but now I'm trying to add new methods but when I compile it all, it says that the Methods I'm calling do not exist. I have even erased the default HelloWorld method and it is still shown by the intellisense widget.
I've verified the Build > Configuration Manager and my service is really compiled. Has anyone any idea what's going on?
Thanks a lot!
|
|
|
|
|
Do you update the service reference at the client side?
|
|
|
|
|
|
Hey guys, I'm trying to create html links of all URL's in a string. I'm calling the function below which seems to be pretty close to my needs, except for when someone enters a link followed by text directly after the url. Somebody with a 'proven technology' solution?
<br />
public static string LinkText(string Input)<br />
{<br />
Regex urlregex = new Regex(@"(http:\/\/([\w.]+\/?)\S*)", RegexOptions.IgnoreCase | RegexOptions.Compiled);<br />
string Output = urlregex.Replace(Input, "<a href=\"$1\" target=\"_blank\">$1</a>");<br />
Regex emailregex = new Regex(@"([a-zA-Z_0-9.-]+\@[a-zA-Z_0-9.-]+\.\w+)", RegexOptions.IgnoreCase | RegexOptions.Compiled);<br />
Output = emailregex.Replace(Output, "<a href=mailto:$1>$1</a>");<br />
return Output;<br />
}<br />
|
|
|
|