|
|
Thanks a lot, i really need this.
|
|
|
|
|
<asp:EntityDataSource ID="srcCity" runat="server" ContextTypeName="Namespace.Core.Tracking.Domain" EntitySetName="Cities"
EntityTypeFilter="City" Include="Country" AutoGenerateWhereClause="true"/>
<WhereParameters/>
<asp:QueryStringParameter Name="Country.ID" Type="Int32"
QueryStringField="CountryID" />
</WhereParameters>
</asp:EntityDataSource>
<asp:EntityDataSource ID="srcCountry" runat="server" ContextTypeName="Namespace.Core.Tracking.Domain"
EntitySetName="Countries" EntityTypeFilter="Country" OrderBy="it.Name"/>
<asp:GridView ID="grid" runat="server" AutoGenerateColumns="False" DataKeyNames="ID" DataSourceID="srcCity">
<MasterTableView DataSourceID="srcCity" EditMode="InPlace">
<asp:TemplateField>
<asp:Label ID="lblName" runat="server"
Text='<%# Eval("Country.Name") %>'/>
</asp:TemplateField>
<EditItemTemplate>
<asp:DropDownList ID="lstCountry" runat="server"
SelectedValue='<%# Eval("ID") %>'DataSourceID="srcCountry"
DataTextField="Name" DataValueField="ID"
AppendDataBoundItems="true">
<ListItems>
<asp:ListItem Text="" Value="" />
</ListItems>
</DropDownList>
</EditItemTemplate>
</MasterTableView>
</GridView>
public partial class City : System.Web.UI.Page{
protected void Page_Load(object sender, EventArgs e){
grid.RowCreated += new GridViewRowEventHandler(grid_RowCreated);
}
void grid_RowCreated(object sender, GridViewRowEventArgs e){
if (e.Row.DataItem != null){
var city = EntityDataSourceExtensions.GetItemObject<City>(e.Row.DataItem);
if(city.Country != null)
(grid.FindControl("lstCountry")as DropDownList).SelectedValue = city.Country.ID.ToString(); <-- Here I got Exception
}
}
}
public static class EntityDataSourceExtensions {
public static TEntity GetItemObject<TEntity>(object dataItem) where TEntity : class {
var entity = dataItem as TEntity;
if(entity != null)
return entity;
var td = dataItem as System.ComponentModel.ICustomTypeDescriptor;
if(td != null)
return (TEntity)td.GetPropertyOwner(null);
return null;
}
}
C# Developer-- Modified Sunday, February 14, 2010 3:22 AM
modified on Sunday, February 14, 2010 3:39 AM
|
|
|
|
|
Please apply proper formating for your code before posting.
Developers generally hate to see the code without proper formatting and hence
your post might be ignored by a lot of members.
|
|
|
|
|
OK,ok, I've done it...
but nobody wantede help
C# Developer
|
|
|
|
|
Hi, I have a problem similar to this post:
http://www.microsoft.com.nsatc.net/communities/newsgroups/en-us/default.aspx?dg=microsoft.public.office.developer.vba&tid=6fc07fd9-3313-4c09-9457-f6971ecafda4&cat=en_US_9477b478-d551-48fe-b931-e0d7ed05ac44&lang=en&cr=US&sloc=&p=1
In this post the original poster has written his code in VB whereas I have written my code in C#
My code for uploading a file:
protected void Button1_Click(object sender, EventArgs e)
{
if (FileUpload1.PostedFile.ContentLength>0)
{
string filename = Path.GetFileName(FileUpload1.PostedFile.FileName);
string storagepath = "D:\\Test\\" + filename;
int contentLen = FileUpload1.PostedFile.ContentLength;
Byte[] data = new Byte[contentLen];
FileUpload1.PostedFile.InputStream.Read(data, 0, contentLen);
savefiletodatabase(data);
FileUpload1.SaveAs(storagepath);
}
}
private void savefiletodatabase(byte[] data)
{
SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ToString());
try
{
SqlCommand command = new SqlCommand("INSERT into dbo.test ([file], [filename], [path]) VALUES (@data, '" + FileName + "', '" + FilePath + "')", connection);
command.Parameters.AddWithValue("data", data);
connection.Open();
command.Connection = connection;
command.ExecuteNonQuery();
}
catch (Exception ex)
{
throw ex;
}
finally { connection.Close(); }
}
The code to retrieve file goes here:
protected void LinkButton1_Click(object sender, EventArgs e)
{
getfile();
}
private void getfile()
{
SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ToString());
try
{
SqlCommand command = new SqlCommand("Select [file] FROM dbo.test where id='" + Id + "'", connection);
SqlDataReader reader;
connection.Open();
command.Connection = connection;
reader = command.ExecuteReader();
if (reader.Read())
{
byte[] data = (byte[])reader[0];
Response.ContentType = "application/octet-stream";
Response.AddHeader("Content-Disposition", "attachment;filename=" + TextBox2.Text);
Context.Response.BinaryWrite(data);
}
}
catch (Exception ex)
{ throw ex; }
finally
{
connection.Close();
}
}
I am giving You the table structure here:
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[test](
[file] [varbinary](max) NULL,
[filename] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[path] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[id] [int] IDENTITY(1,1) NOT NULL
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
please help me out;
also when I uploaded a file to the database it was of 18041 bytes, but when I retrieved it after saving on desktop the size was 19,756 bytes which is increased?Thanks
Shankbond
|
|
|
|
|
shankbond wrote: also when I uploaded a file to the database it was of 18041 bytes, but when I retrieved it after saving on desktop the size was 19,756 bytes which is increased?
I think you need to clear the response using Response.Clear()
It's very important not to use string concatenation to make sql statements. Use parameterized queries instead.
|
|
|
|
|
Hi,
hspc wrote: I think you need to clear the response using Response.Clear()
I did but it does no effect on the size.Thanks
Shankbond
|
|
|
|
|
how to embed a 3rd party vedio conferencing software in asp.netcode?
is it possible in .net3.5?
can anybody suggest me any 3rd party tool for vedio conferencing?
plz its very urgent........
|
|
|
|
|
Which Third party control do you want to embed ?
|
|
|
|
|
any best video conference tool..........
what i need is that user can use that vedio conference from website.
|
|
|
|
|
|
hi,
When i change source of page then designer appears empty as a blank page that no control added to, so i can't change any source ...
thnaks in advance
|
|
|
|
|
right click on page and select convert to webapplication. it will regerate your designer page
Regards
Keyur Satyadev
|
|
|
|
|
thanks , but on right click menu there is no item named convert to web application, this problem accours on user web controls,aspx pages runs normally
|
|
|
|
|
<a id="A1" name="SelectZip" href="javascript:void(0);" onclick="javascript:SelectZip('<%=txtvDemoZip.ClientID%>',
'<%=txtvDemoCity.ClientID %>','<%=txtvDemoState.ClientID %>');"style="vertical-align: middle; font-size: 10pt; color: #4878a9; font-family: Arial; cursor:hand;text-decoration: underline;">Zip</a>
<iframe src="../../../../asps/DummyPage.htm" name="frmzip" id="frmzip" frameborder="0" style="vertical-align: top; text-align: center; width: 0;" marginwidth="0" marginheight="0"scrolling="auto" height="0" tabindex="-1"></iframe>
function SelectZip(txtZipCode,txtCity,txtState)
{
if (document.getElementById(txtZipCode).value == "")
{
alert('Please Enter Zip Code.');
document.getElementById(txtZipCode).focus();
return;
}
else if(document.getElementById(txtZipCode).value.length <5 &&document.getElementById(txtZipCode).value.length > 0 )
{
alert('Please Enter Zip Code.');
document.getElementById(txtZipCode).focus();
return;
}
else
{
strZipp=document.all(txtZipCode).value;
strcity=document.all(txtCity).value;
strstate=document.all(txtState).value;
// document.all("frmzip").src = "frameZip.aspx?cri=" & strZipp & "&vstate=" & strstate & "&vcity=" & strcity & "&From=Registeration" & "&txtCity=" & txtCity & "&txtState=" & txtState;
document.getElementById('frmzip').src = "frameZip.aspx?cri=" + strZipp + "&vstate=" + strstate + "&vcity=" + strcity + "&From=Registeration" + "&txtCity=" + txtCity + "&txtState=" + txtState;
// window.frames("frmzip").location.href = "frameZip.aspx?cri=" + strZipp + "&vstate=" + strstate + "&vcity=" + strcity + "&From=Registeration" + "&txtCity=" + txtCity + "&txtState=" + txtState;
// var URL = "frameZip.aspx?cri=" + strZipp + "&vstate=" + strstate + "&vcity=" + strcity + "&From=Registeration" + "&txtCity=" + txtCity + "&txtState=" + txtState;
}
document.getElementById(txtZipCode).scrollIntoView(true);
}
you can see how many ways i have tried but none worked even i tried to call the function on Href but still no luck. when zip link is clicked it opens a popup which is iframe. it works in IE but firefox no luck yet. Help me out
thank you
Kamran Pervaiz
Asst. Software Engineer
|
|
|
|
|
IFrames are evil. Don't expect them to work in anything but IE.
The ASP.Net way to solve it would probably be something with a asp:Panel with appropriate CSS to layer it on top of everything possibly inside an asp:UpdatePanel. You could create your own, or you could implement the ModalPopupExtender from the Ajax Control Toolkit[^]
|
|
|
|
|
hi guys, do you know of any free sample/implementation of this in .aspx?
http://www.labsmedia.com/clickheat/index.html
http://www.clickdensity.com/
thanks for any info.
|
|
|
|
|
Hi,
i have browse locally in iis.
but it not getting to connect.
its showing error like...
"Failed to access IIS metabase"Yours,
KaNNaN
-----------------------------------------------------------------
"Success is When Ur Signature Becomes An Autograph"
|
|
|
|
|
KaNNaN.JC wrote: its showing error like...
"Failed to access IIS metabase"
I guess your Virtual diretory is not configured properly. Did you set ASP.NET Framework version in IIS for your virtual directory ?
If you are not able to find the proper framework version on IIS, then you need to run aspnet_regiis command to register it.
Thanks.
|
|
|
|
|
Hi
I've enabled my SQL SErver - 2005 for replication, that is i'm running 3 server out of which 1 is master rest all slaves. Now i want to tell my ASP.Net application always write in Master server and Read from rest of two servers? How to achieve it?
|
|
|
|
|
By using different connectionstring to connect to a different server, based on whether you are reading or writing.I are Troll
|
|
|
|
|
i am sending mail through smtp.it is working fine but problem is that when i refresh the page mail again be send.i don't want to send mail again when page will refresh.plz help me.............
this is my code
using System;
using System.Data;
using System.Configuration;
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;
using System.Net;
using System.Net.Mail;
using System.Text;
using System.IO;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Page.Title = "Contact US";
txt_name.Focus();
lbl_status.Visible = false;
}
protected void btn_submit_Click(object sender, EventArgs e)
{
MailMessage mailMsg = new MailMessage("xyz@xyx.in","abc@abc.in");
string name = txt_name.Text.Trim();
string address = txt_add.Text.Trim();
string telnor = txt_telcr.Text.Trim() + "-" + txt_telnr.Text.Trim();
string telnoo = txt_telco.Text.Trim() + "-" + txt_telno.Text.Trim();
string faxno = txt_faxn.Text.Trim();
string mobileno = txt_mobile.Text.Trim();
string typeofwork = rdo_type.Text.Trim();
string query = list_query.Text.Trim();
string Email = Emailid.Text.Trim();
if (Email == "") { Email = "dummyforcheck@in.com"; }
mailMsg.Subject = name + " wants to contact us";
mailMsg.IsBodyHtml = true;
MailMessage mailMsgUser = new MailMessage("xyx@xyz.in", Email);
mailMsgUser.Subject =" Yoyr mail has been recived";
mailMsgUser.IsBodyHtml = true;
mailMsg.Body = "<b> Name :" + name + "<br/><b>Address :"
+ address + "<br/><b>Phone Number(R) :" + telnor + "<br/><b>Phone Number(O) :" + telnoo +
"<br/><b>Fax Number :" + faxno + "<br/><b>Mobile Number :" + mobileno + "<br/><b>Mobile Number :"
+ Email + "<br/><b>Type Of Work :" + typeofwork + "<br/><b>Query :" + query;
mailMsgUser.Body = "<b> Esteemed <br/><b> Dear </b>" + name + "<br/><br/><span style='margin-left:50px'> Thanks for contacting us. Our sales executive will contact you shoon.</span><br/><br/><br/><b>Thank you<br/>Royal Village Team.";
mailMsg.Priority = MailPriority.High;
mailMsgUser.Priority = MailPriority.High;
SmtpClient smtpclnt = new SmtpClient();
NetworkCredential nc = new NetworkCredential("xyx@xyz.in", "xyz");
smtpclnt.Host = "smtp.xyz.in";
smtpclnt.UseDefaultCredentials = false;
smtpclnt.Credentials = nc;
smtpclnt.EnableSsl = false;
try
{
smtpclnt.Send(mailMsg);
smtpclnt.Send(mailMsgUser);
lbl_status.Visible = true;
lbl_status.Text = "Thanks for contacting us.Our sales executive will contact you soon";
clearall();
}
catch(Exception ex)
{
lbl_status.Visible = true;
lbl_status.Text = "Oops! there may be problem in internet connection";
}
}
protected void btn_reset_Click(object sender, EventArgs e)
{
clearall();
}
protected void clearall()
{
txt_name.Text = "";
txt_add.Text = "";
txt_telcr.Text = "";
txt_telnr.Text = "";
txt_telco.Text = "";
txt_telno.Text = "";
txt_faxn.Text = "";
txt_mobile.Text = "";
rdo_type.Text = "";
list_query.Text = "";
Emailid.Text = "";
}
}
|
|
|
|
|
Sorry, but are you sure this is on click event?
because if you send email through on click event it should'nt run on page load.
unless this is onPrerender event.
I guess so...
|
|
|
|
|
Sorry, but are you sure this is on click event?
because if you send email through on click event it should'nt run on page load.
unless this is onPrerender event.
I guess so...
yes i am sure that this is on click event.
it is working correctly.
only problem is that after send mail when i refresh page it will again send the mail.
|
|
|
|