Click here to Skip to main content
15,893,508 members
Home / Discussions / C#
   

C#

 
QuestionAdd controls to a tab page at run-time Pin
CodingLover26-Aug-08 19:25
CodingLover26-Aug-08 19:25 
AnswerRe: Add controls to a tab page at run-time Pin
michael@cohen26-Aug-08 19:32
michael@cohen26-Aug-08 19:32 
QuestionRe: Add controls to a tab page at run-time Pin
CodingLover26-Aug-08 19:53
CodingLover26-Aug-08 19:53 
AnswerRe: Add controls to a tab page at run-time Pin
Mycroft Holmes26-Aug-08 22:07
professionalMycroft Holmes26-Aug-08 22:07 
GeneralRe: Add controls to a tab page at run-time Pin
CodingLover26-Aug-08 22:43
CodingLover26-Aug-08 22:43 
GeneralRe: Add controls to a tab page at run-time Pin
Mycroft Holmes26-Aug-08 22:54
professionalMycroft Holmes26-Aug-08 22:54 
GeneralRe: Add controls to a tab page at run-time Pin
michael@cohen26-Aug-08 23:18
michael@cohen26-Aug-08 23:18 
Questionproblem with the text box Pin
Preeti197926-Aug-08 19:14
Preeti197926-Aug-08 19:14 
There is a big problem for me as I have to handle a project made by an other person and I m not aware of this code.I have two tables in SQL Server 2005 named AudioFileDetails having fields---- FileId int 4, FileName varchar 1000, Subject varchar 500, DistrictId smallint 2 and other table is DistrictDetails with the fields ------- DistrictId smallint 2, DistrictName varchar 100.I have a query form (ASP.NET) that have two fields named Subject and DistrictName, both dropdownlist box with the entries from the database .In this web form there is a button named Go to execute the query.The button is working ie records are displayed according to the value selected from the dropdownlist either from District or from the Subject or from the both.The result is shown in the grid which is given below the GO button.This grid have two fields named Subject and DistrictName and a button named Play ,on which the user can click and play the file that is displayed from the query.When the user click on the play button an another form is displayed that contains a windowsVedioMedia to play that audio file (as the files are audio files), two text boxes that displays two fields subject , DistrictName and a button Save to save the entries if user have edited.These fields contains the value of the subject and DistrictName of the file being played.But my problem is that as subject is directly taken from the AudioFileDetails table that is from the database but the DistrictName value is not coming in the District text box.The district field contains no value in the form ,but there is the entry in the database of that field. fields.Please tell me how can I get the value of District field in that table as in the database there is a field named DistrictId not DistrictName and also a coding to save the edited value also.Please give me in detail as I m not so aware of this language……..i m giving u the entire code used.......some error is there so please let me know.....
_______________________________________________________
AudioSearch.aspx.cs

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.Data.Sqlclient;
public partial class AudioSearch: System.web.UI .Page
{
protected void page_load(object sender,EventArgs e)
{
if(!page.IsPostBack)
{
try
{
DataSet ds1=New DataSet();
DataSet ds2=New DataSet();
AudioSearchClass objch=New AudioSearchClass();
Ds1=objch.GetTheDistrictNames();
ddlDistrictName.Datasource=ds1;
ddlDistrictName.DataTextField=”DistrictName”;
ddlDistrictName.DataValueField=”DistrictId”;
ddlDistrictName.DataBind();
ddlDistrictName.Items.Insert(0,”-Select”);
ds2=objch.GetTheSubject();
ddlSubject.Datasource=ds2;
ddlSubject.DataTextField=”Subject”;
ddlSubject.DataValueField=” Subject Id”;
ddlSubject.DataBind();
ddlSubject.Items.Insert(0,”-Select”);
String Restore=string.Empty;
Restore=Request.QueryString.Get(“Restore”);
If(Restore==”Yes”)
{
ddlSubject.SelectedItem.Text=Session[“SubjectIndex”].ToString(); ddlDistrictName.SelectedIndex=(Convert.ToInt32(Session[“DistrictIndex”] .ToString();
FillGridView();
}
}
catch(Exception ex)
{
}
}
}
protected void btnGo_Click(object sender,EventArgs e)
{
FillGridView();
}
protected void GridView1_SelectedIndexChanged(object sender,EventArgs e)
{
string FileId=(GridView1.DataKeys[GridView1.SelectedIndex][“FileId”].ToString());
string FileName= (GridView1.DataKeys[GridView1.SelectedIndex][“ FileName”].ToString());
string Subject=(GridView1.DataKeys[GridView1.SelectedIndex][“Subject”].ToString());
string DistrictName =(GridView1.DataKeys[GridView1.SelectedIndex][“DistrictName”].ToString());
Session[“FileId _S”]= FileId;
Session[“Subject _S”]= Subject;
Session[“DistrictName _S”]= DistrictName;
Session[“FilePath_S”]= FileName;
Response.Redirect(“AudioDisplay.aspx”);
}
Private void FillGridView()
{
try
{
AudioSearchClass up=New AudioSearchClass();
if(ddlDistrictName.SelectedIndex!=0)
Up.DistrictId=int.parse((string)(ddlDistrictName.SelectedValue));
if(ddlSubject.SelectedValue.Equals(“-Select-“))
Up.Subject= ddlSubject.SelectedValue;
DataSet Gridds=new DataSet();
Gridds=up.GetFilePaths();
GridView1.DataSource=Gridds.Tables[0];
GridView1.DataBind();
if(Gridds.Tables[0].Rows.Count= =0)
{
GridView1.visible=false;
lblmsg.visible=false;
lblmsg.Text=”No Recordings found for your query”;
}
else
{
Session[“SubjectIndex ”]= ddlSubject.SelectedValue;
Session[“DistrictIndex”]= ddlDistrictName.SelectedIndex;
GridView1.visible=True;
lblmsg.visible=True;
lblmsg.Text=”There are”+ Gridds.Tables[0].Rows.Count+”Recordings found for your query”;
}
}
catch(Exception ex)
{
}
}
}
_______________________________________________________
AudioDisplay.aspx.cs


public partial class AudioDisplay: System.web.UI .Page
{
protected void page_load(object sender,EventArgs e)
{
if(!page.IsPostBack)
{
if(CheckSession(“Subject_s”))
txtSubject.Text=Session[“Subject_s”].ToString();
if(CheckSession(“DistrictName_s”))
txt District.Text=Session[“DistrictName_s”].ToString();
}
try
{
if(Session[FilePath_s”]!=null)
windowsMedia1.videoURL=Session[FilePath_s”].ToString();
}
catch(Exception ex)
{
}
}
private bool CheckSession(string Name)
{
if(Session[Name]!=null)
return true;
else
return false;
}
protected void btnSave_Click(object sender,EventArg e)
{
int FileId=0;
if(CheckSession(“FileId_s”)
FileId=Convert.ToInt32(Session[“FileId_s”].ToString();
AudioDisplayClass objDis=New AudioDisplayClass();
objDis.Subject=txtSubject.Text;
objDis.DistrictName=txtDistrict.Text;
objDis.FileId=FileId;
objDis.UpdateFileDetails();
lblEMsg.Text=”Updated Successfully”;
}
_______________________________________________________
AudioDisplayClass.cs


Public Class AudioDisplayClass
{
public DataBase mDataBaseObject;
private int mFileId=0;
private int mDistrictId=0;
private string mSubject=String.Empty;
private string mDistrictName=String.Empty;
public String DistrictName
{
get {return mDistrictName;}
set{mDistrictName=value;}
}
public String Subject
{
get {return mSubject;}
set{mSubject =value;}
}
public int DistrictId
{
get {return mDistrictId;}
set{ mDistrictId =value;}
}
public AudioDisplayClass()
{
mDataBaseObject=DataBaseFactory.CreateDataBase();
}
public void UpdateFileDetails()
{
try
{
DataBase objDB=mDataBaseobject;
System.Data.Common.DBCommand =objDB.GetStoredProcCommand(“UpdateAudioFileDetails”);
objDB.AddInParameter(objCommand,”@FileId”,DBType.String,mFileId);
objDB.AddInParameter(objCommand,”@Subject.String,mSubject);
objDB.AddInParameter(objCommand,”@DistrictName.String,mDistrictName);
}
catch(Exception ex)
{
}
}
_______________________________________________________
AudioSearchClass.cs


Public Class AudioSearchClass
{
public DataBase mDataBaseObject;
private int mDistrictId=0;
private string mSubject=String.Empty;
private string mDistrictName=String.Empty;
public String DistrictName
{
get {return mDistrictName;}
set{mDistrictName =value;}
}
public String Subject
{
get {return mSubject;}
set{mSubject =value;}
}
public int DistrictId
{
get {return mDistrictId ;}
set{ mDistrictId =value;}
}
public AudioSearchClass()
{
mDataBaseObject=DataBaseFactory.CreateDataBase();
}
public Dataset GetFilePaths()
{
Dataset ds=new Dataset();
try
{
DataBase objDB=mDataBaseobject;
System.Data.Common.DBCommand objCommand=objDB.GetStoredProcCommand(“GetAudioFiles”);
objDB.AddInParameter(objCommand,”@Subject,DbType.String,mSubject);
objDB.AddInParameter(objCommand,”@DistrictId,DbType.String,mDistrictId);
ds=objDB.ExecuteDataSet(objCommand);
}
catch(Exception ex)
{
}
return ds;
}
}
_______________________________________________________

Stored Procedure:- UpdateAudioFileDetails


Create Procedure UpdateAudioFileDetails
( @FileId int,
@Subject varchar(100),
@DistrictId smallint 2
)
as
begin
update[dbo].[AudioFileDetails]
set
subject=@subject
DistrictId=@DistrictId
Where FileId=@FileId
End
Go

preeti1979
AnswerRe: problem with the text box Pin
AhsanS26-Aug-08 19:43
AhsanS26-Aug-08 19:43 
QuestionGdi+ Memory Leak >Scrolling text Pin
michael@cohen26-Aug-08 19:06
michael@cohen26-Aug-08 19:06 
AnswerRe: Gdi+ Memory Leak >Scrolling text Pin
leppie26-Aug-08 22:00
leppie26-Aug-08 22:00 
GeneralRe: Gdi+ Memory Leak >Scrolling text Pin
Mycroft Holmes26-Aug-08 22:12
professionalMycroft Holmes26-Aug-08 22:12 
GeneralRe: Gdi+ Memory Leak >Scrolling text Pin
leppie26-Aug-08 22:19
leppie26-Aug-08 22:19 
GeneralRe: Gdi+ Memory Leak >Scrolling text Pin
michael@cohen26-Aug-08 22:58
michael@cohen26-Aug-08 22:58 
QuestionWindows Servce in windows application Problem Pin
idreesbadshah26-Aug-08 18:16
idreesbadshah26-Aug-08 18:16 
AnswerRe: Windows Servce in windows application Problem Pin
Ashfield26-Aug-08 21:10
Ashfield26-Aug-08 21:10 
GeneralRe: Windows Servce in windows application Problem Pin
idreesbadshah26-Aug-08 22:17
idreesbadshah26-Aug-08 22:17 
GeneralRe: Windows Servce in windows application Problem Pin
Ashfield27-Aug-08 2:52
Ashfield27-Aug-08 2:52 
Question.Net Framework version issue Pin
George_George26-Aug-08 16:52
George_George26-Aug-08 16:52 
AnswerRe: .Net Framework version issue Pin
Brij26-Aug-08 17:54
mentorBrij26-Aug-08 17:54 
GeneralRe: .Net Framework version issue Pin
George_George26-Aug-08 18:06
George_George26-Aug-08 18:06 
AnswerRe: .Net Framework version issue Pin
N a v a n e e t h26-Aug-08 17:54
N a v a n e e t h26-Aug-08 17:54 
GeneralRe: .Net Framework version issue Pin
George_George26-Aug-08 18:04
George_George26-Aug-08 18:04 
AnswerRe: .Net Framework version issue Pin
Abhijit Jana26-Aug-08 17:56
professionalAbhijit Jana26-Aug-08 17:56 
GeneralRe: .Net Framework version issue Pin
George_George26-Aug-08 18:05
George_George26-Aug-08 18:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.