Click here to Skip to main content
15,923,051 members
Home / Discussions / ASP.NET
   

ASP.NET

 
Questionhelp c# Pin
ptvce10-Jan-10 22:57
ptvce10-Jan-10 22:57 
Questionemail Pin
mylogics10-Jan-10 22:22
professionalmylogics10-Jan-10 22:22 
AnswerRe: email Pin
Vimalsoft(Pty) Ltd11-Jan-10 2:20
professionalVimalsoft(Pty) Ltd11-Jan-10 2:20 
GeneralRe: email Pin
mylogics11-Jan-10 19:35
professionalmylogics11-Jan-10 19:35 
GeneralRe: email Pin
Vasudevan Deepak Kumar12-Jan-10 4:09
Vasudevan Deepak Kumar12-Jan-10 4:09 
QuestionDelete record in Gridview Pin
Nopo10-Jan-10 21:46
Nopo10-Jan-10 21:46 
AnswerRe: Delete record in Gridview Pin
Dinesh Mani10-Jan-10 22:14
Dinesh Mani10-Jan-10 22:14 
GeneralRe: Delete record in Gridview Pin
Nopo10-Jan-10 22:36
Nopo10-Jan-10 22:36 
I'm using dataTable as staorage and then I save it in a Session. Here is the code.

private void DataBindGrid()
{
try
{

string checkflag;

//Create DataTable.
DataTable dt = (DataTable)Session["dtInfoProfile"];

if (dt == null)
{
//Create DataTable.
dt = new DataTable();

//Assign Columns to it.
dt.Columns.Add(new DataColumn("Full Names"));
dt.Columns.Add(new DataColumn("Type"));
dt.Columns.Add(new DataColumn("Identifying Number"));
dt.Columns.Add(new DataColumn("Passport Number"));
}

//Create a DataRow by dt.NewRow().
DataRow dr = dt.NewRow();

if (rdbIndividual.Checked)
{
//Fill that row and add it to datatable.
checkflag = rdbIndividual.Text;
dr["Full Names"] = IndividualDetailsControl.FirstName + " " + IndividualDetailsControl.LastName;
dr["Type"] = checkflag;
dr["Identifying Number"] = IndividualDetailsControl.IdentityNo;
dr["Passport Number"] = IndividualDetailsControl.PassportNo;
dt.Rows.Add(dr);
}
else if (rdbTrust.Checked)
{
checkflag = rdbTrust.Text;
//Fill that row and add it to datatable.
dr["Full Names"] = EntityDetailsControl.Name;
dr["Type"] = checkflag;
dr["Identifying Number"] = EntityDetailsControl.RegistrationNo;
dt.Rows.Add(dr);
}
else
{
checkflag = rdbEntity.Text;
//Fill that row and add it to datatable.
dr["Full Names"] = EntityDetailsControl.Name;
dr["Type"] = checkflag;
dr["Identifying Number"] = EntityDetailsControl.RegistrationNo;
dt.Rows.Add(dr);

}

Session["dtInfoProfile"] = dt;

//Bind GridView Here with this Table
this.BindData();

//Rename the button
btnAdd.Text = "Add New";

}
catch (Exception ex)
{
Response.Write(ex.Message);
}
}

private void BindData()
{
dgInfoProfile.DataSource = Session["dtInfoProfile"];
dgInfoProfile.DataBind();
}



For Edit and Update:

//Edit
protected void dgInfoProfile_RowEditing(object sender, GridViewEditEventArgs e)
{
//Set the edit index.
dgInfoProfile.EditIndex = e.NewEditIndex;
//Bind data to the GridView control.
this.BindData();
}

//Update
protected void dgInfoProfile_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
//Retrieve the table from the session object.
DataTable dt = (DataTable)Session["dtInfoProfile"];

//Update the values.
GridViewRow row = dgInfoProfile.Rows[e.RowIndex];
dt.Rows[row.DataItemIndex]["Full Names"] = ((TextBox)(row.Cells[1].Controls[0])).Text;
dt.Rows[row.DataItemIndex]["Type"] = ((TextBox)(row.Cells[2].Controls[0])).Text;
dt.Rows[row.DataItemIndex]["Identifying Number"] = ((TextBox)(row.Cells[3].Controls[0])).Text;
dt.Rows[row.DataItemIndex]["Passport Number"] = ((TextBox)(row.Cells[4].Controls[0])).Text;

//Reset the edit index.
dgInfoProfile.EditIndex = -1;

//Bind data to the GridView control.
this.BindData();
}
GeneralRe: Delete record in Gridview Pin
Dinesh Mani10-Jan-10 22:50
Dinesh Mani10-Jan-10 22:50 
GeneralRe: Delete record in Gridview Pin
Nopo10-Jan-10 22:59
Nopo10-Jan-10 22:59 
GeneralRe: Delete record in Gridview Pin
Dinesh Mani10-Jan-10 23:05
Dinesh Mani10-Jan-10 23:05 
GeneralRe: Delete record in Gridview Pin
Nopo10-Jan-10 23:23
Nopo10-Jan-10 23:23 
GeneralRe: Delete record in Gridview Pin
Dinesh Mani10-Jan-10 23:32
Dinesh Mani10-Jan-10 23:32 
AnswerRe: Delete record in Gridview Pin
Nopo11-Jan-10 2:51
Nopo11-Jan-10 2:51 
GeneralRe: Delete record in Gridview Pin
Dinesh Mani11-Jan-10 18:35
Dinesh Mani11-Jan-10 18:35 
QuestionProblem with Remember password Pin
Sudhanshu Mani Tripathi10-Jan-10 19:33
Sudhanshu Mani Tripathi10-Jan-10 19:33 
GeneralRe: Problem with Remember password Pin
lxdx10-Jan-10 19:48
lxdx10-Jan-10 19:48 
QuestionSelecting picture by open file dialoguebox and showing it in imagebox in ASP.NET Pin
Abdullah Al-Muzahid10-Jan-10 19:31
professionalAbdullah Al-Muzahid10-Jan-10 19:31 
AnswerRe: Selecting picture by open file dialoguebox and showing it in imagebox in ASP.NET Pin
lxdx10-Jan-10 19:50
lxdx10-Jan-10 19:50 
GeneralRe: Selecting picture by open file dialoguebox and showing it in imagebox in ASP.NET Pin
Abdullah Al-Muzahid10-Jan-10 20:03
professionalAbdullah Al-Muzahid10-Jan-10 20:03 
Questionmagic numbers when debug in a webform Pin
meeram39510-Jan-10 19:11
meeram39510-Jan-10 19:11 
GeneralRe: magic numbers when debug in a webform Pin
J a a n s11-Jan-10 0:12
professionalJ a a n s11-Jan-10 0:12 
GeneralRe: magic numbers when debug in a webform Pin
meeram39511-Jan-10 0:49
meeram39511-Jan-10 0:49 
QuestionOpening URL in new browser from ASP.net Pin
Hema Bairavan10-Jan-10 19:03
Hema Bairavan10-Jan-10 19:03 
AnswerRe: Opening URL in new browser from ASP.net Pin
meeram39510-Jan-10 19:20
meeram39510-Jan-10 19:20 

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.