Click here to Skip to main content
16,004,974 members
Home / Discussions / ASP.NET
   

ASP.NET

 
QuestionWhy don't images appear in Visual Web Designer? Pin
asdf98911-Nov-08 11:21
asdf98911-Nov-08 11:21 
AnswerRe: Why don't images appear in Visual Web Designer? Pin
asdf98923-Nov-08 8:13
asdf98923-Nov-08 8:13 
QuestionTable height is not being displayed at 100% Pin
y.aitelmaati11-Nov-08 10:43
y.aitelmaati11-Nov-08 10:43 
AnswerRe: Table height is not being displayed at 100% Pin
Brij11-Nov-08 17:20
mentorBrij11-Nov-08 17:20 
QuestionSQL Query and .Net code for Advanced search in my application ?? Pin
babisharma11-Nov-08 10:33
babisharma11-Nov-08 10:33 
AnswerRe: SQL Query and .Net code for Advanced search in my application ?? Pin
babisharma11-Nov-08 11:10
babisharma11-Nov-08 11:10 
QuestionAppDomain could not be created Runtime Error Pin
RB@Emphasys11-Nov-08 10:23
RB@Emphasys11-Nov-08 10:23 
Questiondynamically adding rows in gridview Pin
Mogaambo11-Nov-08 9:16
Mogaambo11-Nov-08 9:16 
hi, what i am trying to do is , when a button is clicked a row should be added containing one column with a textbox in gridview.

For that i have used datatable for binding,, but i am unable to get the added textbox reference using find control method

here is my cs code.





using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class _Default : System.Web.UI.Page
{

protected void Page_Load(object sender, EventArgs e)
{

if (!IsPostBack)
{
loadDynamicGrid();
}
}

private void loadDynamicGrid()
{
DataTable dt = new DataTable();
DataColumn dcol = new DataColumn();
dcol.ColumnName = "gggg";
dt.Columns.Add(dcol);
DataRow drow = dt.NewRow();
dt.Rows.Add(drow);
GridView1.DataSource = dt;
GridView1.DataBind();

}

protected void Button1_Click(object sender, EventArgs e)
{
DataTable dt = new DataTable();

DataColumn dcol = new DataColumn("gggg");

dt.Columns.Add(dcol);

foreach (GridViewRow gvr in GridView1.Rows)
{
DataRow drow= dt.NewRow();
TextBox tt = (TextBox)gvr.Cells[0].FindControl("Text1");
drow[0] = tt.Text;//Here gives error as it is always null
dt.Rows.Add(drow);
}

DataRow dr = dt.NewRow();
dr[0] = "";
dt.Rows.Add(dr);
GridView1.DataSource = dt;
GridView1.DataBind();

}

protected void GridView1_RowDataBound1(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
TextBox tb = new TextBox();
tb.ID = "Text1";
tb.Text = "chanu";
e.Row.Cells[0].Controls.Add(tb);

}
}
}

//here is my aspx code


]]>





<title>Untitled Page








<asp:scriptmanager id="ScriptManager1" runat="server" xmlns:asp="#unknown">

<asp:updatepanel id="UpdatePanel1" runat="server" xmlns:asp="#unknown">
<contenttemplate>
<asp:gridview id="GridView1" runat="server">
Width="200px"


onrowdatabound="GridView1_RowDataBound1" >
<columns>

<asp:button id="Button1" runat="server" onclick="Button1_Click" text="Button">










“You will never be a leader unless you first learn to follow and be led.”
–Tiorio

"Coming together is a beginning, staying together is progress, and working together is success." Henry Ford

QuestionExport to Excel Pin
kishorg111-Nov-08 3:46
kishorg111-Nov-08 3:46 
AnswerRe: Export to Excel Pin
jzonthemtn11-Nov-08 5:06
jzonthemtn11-Nov-08 5:06 
GeneralRe: Export to Excel Pin
kishorg112-Nov-08 0:06
kishorg112-Nov-08 0:06 
QuestionValidation Pin
shanthi jothi11-Nov-08 2:27
shanthi jothi11-Nov-08 2:27 
AnswerRe: Validation Pin
Brij11-Nov-08 3:13
mentorBrij11-Nov-08 3:13 
AnswerRe: Validation Pin
jzonthemtn11-Nov-08 5:05
jzonthemtn11-Nov-08 5:05 
Questionadding multiple records Pin
Mogaambo11-Nov-08 2:10
Mogaambo11-Nov-08 2:10 
QuestionDatetime Pin
shanthi jothi11-Nov-08 1:53
shanthi jothi11-Nov-08 1:53 
AnswerRe: Datetime Pin
Guffa11-Nov-08 3:08
Guffa11-Nov-08 3:08 
Questiontab control with same position Pin
r aa j11-Nov-08 1:39
r aa j11-Nov-08 1:39 
AnswerRe: tab control with same position Pin
J a a n s11-Nov-08 1:55
professionalJ a a n s11-Nov-08 1:55 
GeneralRe: tab control with same position Pin
r aa j11-Nov-08 1:58
r aa j11-Nov-08 1:58 
GeneralRe: tab control with same position Pin
J a a n s11-Nov-08 4:19
professionalJ a a n s11-Nov-08 4:19 
QuestionSaving upLoaded File with Client Call Back Pin
Ajeet mittal11-Nov-08 1:37
Ajeet mittal11-Nov-08 1:37 
QuestionRetain link Color? Pin
Prasadsm11-Nov-08 1:30
Prasadsm11-Nov-08 1:30 
AnswerRe: Retain link Color? Pin
Ashfield11-Nov-08 1:32
Ashfield11-Nov-08 1:32 
GeneralRe: Retain link Color? Pin
Prasadsm11-Nov-08 2:18
Prasadsm11-Nov-08 2:18 

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.