Working With Sql Datasource In Code Behind?
Jan 21, 2010
i have sp in sql server 2000 naed as get_job_by_jobType and it execute as returning table rows and get thedata in sql datasouce and i want to bind it on gridview,and i m executing storedprocedure on the basis of selectitem from dropdownlist.please tell me hwo to write code in code behind
Code:
Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged
Response.Write(DropDownList1.SelectedItem.Text)
' Me.GridView1.DataSource = DataSourceID
Me.GridView1.DataSourceID = Me.SqlDataSource4.ToString()
End Sub
above statment giving me errors(exception)
View 7 Replies
Similar Messages:
Aug 19, 2010
My application is working fine in local environment but not working after push code in live. My locale environment and hosting environment both are having same configuration. Same app working fine 2 month before but in different domain but same hosting server.
how to check the both config / any possible to run debug mode in hosting server please let me know. below code used in all page for checking user session status but when I click on any link page redirect to login.aspx I think session got timeout. I don't know why session got time frequently, but this issue not happening in local environment (desktop).
[Code]....
[Code]....
View 6 Replies
Aug 28, 2010
If Not IsDBNull(ext) Then
ext = LCase(ext)
End If
Select Case ext
'Case ".htm", ".html"
' type = "text/HTML"
'Case ".txt"
' type = "text/plain"
'Case ".doc", ".rtf"
' type = "Application/msword"
'Case ".csv", ".xls"
' type = "Application/x-msexcel"........................
View 5 Replies
May 21, 2010
I mean, what is the faster way to get as fast as I can more than one table with stored procedure? Is there any study what is faster and why? There is a big problem getting more than one table at once with Entities, so the only way is DataSet. But I was told DataSet work very slow. Is that true?
View 2 Replies
Jul 9, 2010
Am trying to get a working enity model with foreign keys working but have run into a problem. I have imported 3 tables with content and some data.Lets call these tables geo_countries, geo_counties, geo_municipalities and the FK are:1. geo_county have a column country_id wich corresponds to country_id in geo_country 2. geo_municipality have a column county_id wich correspond to the county_id in geo_county.The problem i have is when i try to get correspondig child items with the following code i run into trouble:
[Code]....
The problem above is that 'test' generates results but not 'test2', wich never return anything. Am i not supposed to be able to do it like i do in 'test2'? I earlier tried to add a child object by replacing ToList() with Add() and that worked. But i cant seem to get anything out of it.
View 4 Replies
Dec 1, 2010
im explaining this base on a test page that i have hosted as i was trying to track down my problem, i have a hosted page which i have hosted on the internet on a hosting service provider. the page has a normal gridview that is linked to a SqlDataSource. and theSqlDataSource has sql statements for selecting data, updating and deleting. They all work fine locally and even if i host them locally through IIS. but on the hosting service they down work. only the select work, which means i can view my data on the gridview but i cant manipulate it, delete and updating dont wanna work, they dont do anything. and the worse part is that im not even getting an error from them, on the grid i have enabled the autogenerate edit button and the delete, how can i make the update and delete work, or what is it that makes them not to work. the code for my test page is below
[Code]....
View 2 Replies
Apr 16, 2010
Can the select command of a SqlDataSource be given by code in the code behind file. Also by calling the SqlDataSource.Select can the select statement be executed?
View 3 Replies
Dec 3, 2010
I want to bind an ObjectDataSource to a property in my asp page and I want to do it in the page's aspx code, not in code-behind. I've already done it in code-behind, as follows:
[Code]....
I'd prefer to get rid of the ugly code-behind and just do this in mark-up. Something like
[Code]....
This gives me a run-time error: Cannot create an object of type 'System.Object' from its string representation 'SelectedBook' for the 'DataSource' property.Is there a way of doing this declaratively and not in code-behind? Further, what if what I want is to actually use a child property of the property in question? For example, if my Book object has a ReaderComments collection, can I databind to it decaratively in the aspx mark-up?
View 1 Replies
Jul 15, 2010
I wanted to disable a button after it is clicked and at the same time fire the post back event to generate a report. My first set of code did not work because soon after the button is disabled the page won't submit/post back. here's the first set of code which was not implemented. the onclientclick calls a javascript function which has these lines
document.getElementById('btnGenerateReport').disabled=true;
GetPostBackEventReference(btnGenerateReport,'');
since it was not posting back,i tried the following on page_load code behind
btnGenerateReport.Attributes.Add("onclick", "this.disabled=true;" + ClientScript.GetPostBackEventReference(btnGenerateReport, ""))
that worked well. but I tried to copy the javascript that got generated and pasted directly on design view
onclick="this.disabled=true;__doPostBack('btnDownloadClientsWithConviction','');"
its not working from client side alone after I disable the code behind attributes.add
but when I check the view source the 2 pages are the samewhy am I not able to move the code from code-behind to design view?
View 1 Replies
Mar 25, 2010
I need to pass the control parameter to Sql Datasource in code behind,
<asp:ControlParameter ControlID="DDL_RType" Name="rtype" PropertyName="SelectedValue"
View 3 Replies
May 26, 2010
this is the code for menu CSS code. It will work on Firefox but not in IE6.
.menu li a:hover .menu ul li:hover a{
background-image:url(images/ye.jpg);
color:#000000;
text-decoration:none;
}
View 4 Replies
Jul 7, 2010
Its regarding send mail via c#.net. The following code is working well in my local machine, upload it in server but its not working in server. I m using same smtp server name , email username , password in local and server. But i don't know what is problem? problem is in my coding?
System.Net.Mail.MailMessage objEmail = new System.Net.Mail.MailMessage();
objEmail.From = new MailAddress(dsAdmin.Tables[0].Rows[0]["Emailusername"].ToString());
objEmail.To.Add(To_Tmail.ToString());
objEmail.IsBodyHtml = true;
objEmail.Subject = Subject.ToString();
objEmail.Body = message.ToString() + dsAdmin.Tables[0].Rows[0]["Emailsignature"].ToString();
SmtpClient client = new SmtpClient();
System.Net.NetworkCredential SMTPUserInfo = new System.Net.NetworkCredential(dsAdmin.Tables[0].Rows[0]["Emailusername"].ToString(), dsAdmin.Tables[0].Rows[0]["Password"].ToString());
client.UseDefaultCredentials = false;
client.Credentials = SMTPUserInfo;
client.Host = dsAdmin.Tables[0].Rows[0]["SMTPservername"].ToString();
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.Port = 587;
try
{
client.Send(objEmail);
res = true;
catch (Exception exc)
{
res = false;
}
View 5 Replies
Jun 16, 2010
Code:
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
[code]....
no alert box is displayed when i left the textbox blank and clicked the button
View 37 Replies
Jan 28, 2010
Ok so I have my aspx pages. They work and display fine in IE, but dont do a think in FF. Perfect example is the home page, it has a large image that is set a url that is retrieved from my db in the code behind:
// add main image of home page
imgMain.ImageUrl =
DAL.imagePath();
[Code]....
View 5 Replies
Apr 26, 2010
I've made a login page but I seem to have missed something and I guess I've become blind to the code because I can't find what's wrong with it. I'm sorry some of it's in swedish. There's no error message when I test the login, the program just stays on the login page.
Login page (aspx.cs):
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Text;
using System.IO;
public partial class Start : System.Web.UI.Page
{
string config = System.Configuration.ConfigurationManager.ConnectionStrings["InteraktivaFĂreningenConnectionString1"].ToString();
protected void Page_Load(object sender, EventArgs e)
{
this.TextBoxAnvändarnamn.Focus();
}
protected void ButtonLoggaIn_Click(object sender, EventArgs e) //login-button
{
//kontroll av användarnamn och lĂsenord - controls username and password
try
{
SqlConnection conn = new SqlConnection(config);
{
conn.Open();
string Användarnamn = this.TextBoxAnvändarnamn.Text; //username
string LĂsenord = this.TextBoxLĂsenord.Text; //password
string sql = "SELECT Login.anvandarnamn, Login.losenord, Medlem.ID FROM Login, Medlem WHERE anvandarnamn = '" + Användarnamn + "' AND '" + Session["användarnamn"] + "'";
SqlCommand comm = new SqlCommand(sql, conn);
SqlDataReader dr = comm.ExecuteReader();
{
try
{
dr.Read();
if (Convert.ToString(dr["anvandarnamn"]) == Användarnamn) //username
{
Session["användarnamn"] = TextBoxAnvändarnamn.Text; //username
Session["medlemID"] = dr["medlemID"].ToString(); //memberID
if (Convert.ToString(dr["losenord"]) == LĂsenord)
{
HämtaID(); //getID
Response.Redirect("MĂten.aspx");
}
else
{
string scriptet = "<script>alert('LĂsenordet är felaktigt. Prova igen');</script>"; //wrong password
ClientScript.RegisterStartupScript(scriptet.GetType(), "FelLĂsen", scriptet);
TextBoxLĂsenord.Focus();
}
}
}
catch (Exception)
{
string scriptet = "<script>alert('Användarnamnet är felaktigt. Prova igen.');</script>"; //wrong username
ClientScript.RegisterStartupScript(scriptet.GetType(), "FelAnvändarnamn", scriptet);
TextBoxAnvändarnamn.Focus();
}
dr.Close();
conn.Close();
}
}
}
catch (Exception)
{
}
}
//gets and creates session variables of username and memberID
public void HämtaID() //getID
{
try
{
SqlConnection conn = new SqlConnection(config);
{
conn.Open();
string Användarnamn = this.TextBoxAnvändarnamn.Text; //username
string sql = "SELECT fornamn, efternamn, ID FROM Medlem WHERE ID = '" + Session["medlemID"] + "'";
SqlCommand comm = new SqlCommand(sql, conn);
SqlDataReader dr = comm.ExecuteReader();
{
while (dr.Read())
{
Session["medlemID"] = dr["medlemID"].ToString(); //memberID
Session["användarnamn"] = dr["fornamn"].ToString() + " " + dr["efternamn"].ToString(); //username
}
}
dr.Close();
conn.Close();
}
}
catch (Exception)
{
}
}
}
View 16 Replies
Feb 1, 2011
This code is working in firefox but on IE 8 it returns nothing
<script type="text/javascript">
$(document).ready(function(){
var pageUrl = '<%=ResolveUrl("~/test/test.aspx")%>';
// Test
$('#<%=ddlTest.ClientID%>').change(function(){
var trgId = $(this+'input:checked').val();
$.ajax({
type: "POST",........
View 1 Replies
Mar 8, 2010
I have the following entries in the css file.
a.intervalLinks { font-size:11px; font-weight:normal; color:#003399; text-decoration:underline; margin:0px 16px 0px 0px; }
a.intervalLinks:link { text-decoration:underline; }
a.intervalLinks:hover { text-decoration:none; }
a.intervalLinks:visited { text-decoration:underline; }
a.selectedIntervalLink { font-size:12px; font-weight:bold; color:#003399; text-decoration:none; margin:0px 16px 0px 0px; }
a.intervalLinks:active { text-decoration:underline; font-size:large ; }
Edited for trial:
a.big-link:link{}
a.big-link:visited {}
a.big-link:hover{}
a.big-link:active{font-size:1em;}
Whenever i take the click on some links (not shown) which is embedded in the webpage ..i can see the change in the link
a.intervalLinks:active { text-decoration:underline; font-size:large ;
(the font of the link will become large)
but after clicking the page refreshes ..the changes will go away
i want to keep the change for ever in that link ...even there is a page refresh
i understood that ..this can achieved only throughg the code behind of asp.net
Following code should work:but unfortunately its not
protected override void OnInit(EventArgs e)
{
rptDeptList.ItemDataBound += new RepeaterItemEventHandler(rptDeptList_ItemDataBound);
}
void rptDeptList_ItemDataBound(object sender, RepeaterItemEventArgs e)
[Code]....
View 3 Replies
Jan 19, 2010
<script language="JavaScript" type="text/javascript">
if (location.href.indexOf('?dest=') > 0)
window.open('/about.aspx', '', '')
</script>
how do i make this work. Its in aspx file.
View 3 Replies
Jul 22, 2010
Below is some code. The save() method was pre-existing. I added the saveRanking() method. When I walk through the code, it hits the method, but then it just bails out of it. No exception (that I can see). Do I need that function(data) part?
Code:
function save() {
$.post(
"/Applications/SaveStatus",
[code]....
View 1 Replies
Oct 21, 2010
i am added one button on user control it is working fine locally but not working on server my error is CS1061: 'ASP.templates_categories_productsingrid_ascx' does not contain a definition for 'dl_viewall' and no extension method 'dl_viewall' accepting a first argument of type 'ASP.templates_categories_productsingrid_ascx' could be found (are you missing a using directive or an assembly reference?)
View 2 Replies
Dec 18, 2010
[Code]....
[Code]....
//Ideally this should hide al the anchor tags with in tr tag. But this piece of code is not working as expected. nothing is fading out. [Code]....
View 3 Replies
Apr 1, 2011
I've a very complete site in ASP.NET wich uses iframes. I'm working to change an old control we'd been using to show dialogs to use jQuery UI dialogs. I'm also making sure everything works well in IE9.
The fact is: the script I've in the pages shown in iframes is not working in IE9. Why? Because Object, Array and String are undefined. There may be some others issues, I've seen only this ones.
There is no chance (because a lot of reasons) to stop using iframes on some dialogs. And I'd rather not to use the meta tag to force IE8 Compability. Does anyone know any way to fix this uggly bug in IE9?
Edit
Here there's some info that may be helfull:
jQuery code for the iframe in a plugin I've made to config jQuery UI dialog:
options.content = $("<iframe>")
.attr("src", options.intSrcIframe)
.attr("frameborder", 0)
.attr("scrolling", options.intIframeScrolling)
.css("background-color", options.intBgColorIframe)
.attr("height", "100%")
.attr("width", "100%");
_this.html(options.content);
View 1 Replies
Oct 21, 2010
This is from a very good book by Steven SandersonI am trying to follow the chapter 4 and trying to setup IOC on my mvc code from the code sample of the book but its not working.I follow the code from page 97 to page 101 where I set up Inversion of Control and run the code but I get the following error. A dialog box opens trying to search the following file:
c:TeamCityuildAgentwork1ab5e0b25b145b19srcCastle.WindsorWindsorWindsorContainer.cs
protected override IController GetControllerInstance(
System.Web.Routing.RequestContext requestContext,
Type controllerType)
[code]...
View 3 Replies
Jul 19, 2010
I fired up my first asp.net 4 app put together with visual studio 2010 and IIS doesn't seem to compile my code behinds on the fly for some reason, I have to build the site manually.
How do I configure my app to compile code behinds on the fly? I looked around but I must be missing something. Never had this issue before.
View 1 Replies
Nov 26, 2010
This same code working fine with MVC 2 but not working in MVC 3 razor. Once page is loaded not loading menu from HTMLHelper called within Razor like below.
Hardcoded menu for testing which is not outputting on the page.
[Code]....
Below is Razor cshtml code.
[Code]....
View 3 Replies