This is a migrated thread and some comments may be shown as answers.

[Solved] After button click get the value of editable column issue.

2 Answers 154 Views
Grid
This is a migrated thread and some comments may be shown as answers.
saroja
Top achievements
Rank 1
saroja asked on 13 Aug 2009, 06:11 AM

Hai! I have editable radgrid with two columns..one is subject column and another one is marks column..I have dropdownlist_index changed event..In this event  change subject's  depend on dropdownlist selected value in grid..In run time I enter marks in marks column and then click button1..In button1 click event I need to get the value of editable column...but I can not get  run time editable value..I can get only column default value that is 0..why i cannot get the runtime edited value.. can anyone help me? 
protected
void Button1_Click(object sender, EventArgs e)

 

{

 

foreach (GridEditableItem grdRow in grdMarksEntry.Items)

 

{

 

string str = (grdRow["Marks"].Controls[0] as TextBox).Text;

 

}

 

}

 

 

 

protected void grdMarksEntry_ItemCreated(object sender, GridItemEventArgs e)

 

{

 

for (int i = 0; i <= grdMarksEntry.PageSize; i++)

 

{

 

grdMarksEntry.EditIndexes.Add(i);

 

}

}

 

protected void grdMarksEntry_ColumnCreated(object sender, GridColumnCreatedEventArgs e)

 

{

 

if (e.Column.UniqueName == "Id")

 

{

e.Column.Visible =

false;

 

}

}

 

 

protected void DDLCourses_SelectedIndexChanged(object sender, EventArgs e)

 

{

 

SqlConnection Cnn = new SqlConnection();

 

Cnn.ConnectionString =

@"Data Source=DEVI\SQLEXPRESS;Initial Catalog=Acarin_SchoolManagement;Integrated Security=True";

 

Cnn.Open();

 

DataSet ds = new DataSet();

 

 

SqlCommand cmd = new SqlCommand("SELECT SubjectName,Id FROM [tblCourseSubject] WHERE ([CourseId] = '" + DDLCourses.SelectedValue + "' )", Cnn);

 

 

SqlDataReader dr = cmd.ExecuteReader();

 

 

DataTable dt = new DataTable("StudentMarks");

 

dt.Load(dr,

LoadOption.OverwriteChanges);

 

ds.Tables.Add(dt);

 

DataColumn dc = new DataColumn("Marks", System.Type.GetType("System.Int32"));

 

dc.DefaultValue =

"0";

 

dc.ReadOnly =

false;

 

ds.Tables[

"StudentMarks"].Columns.Add(dc);

 

ds.Tables[

"StudentMarks"].Columns[0].ReadOnly = true;

 

grdMarksEntry.DataSource =

null;

 

grdMarksEntry.DataSource = ds;

grdMarksEntry.DataBind();

 

}

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 13 Aug 2009, 07:59 AM
Hello Saroja,

I tried the same code as yours at my end and was able to retrieve the updated value from the textbox. Have you by any chance disabled the ViewState of the grid, as I was able to replicate your issue when I disabled the view state of the grid. If so, you would have to enable  ViewState for the control to retrieve updated values on postback.

Thanks
Princy.
0
saroja
Top achievements
Rank 1
answered on 13 Aug 2009, 08:57 AM
hi mam!

As what u told I tried ...I set enableviewstate true for grid...but still now i can't get updated value from radgrid.. can u tell any alternative methods?
 
Tags
Grid
Asked by
saroja
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
saroja
Top achievements
Rank 1
Share this question
or