I am new to mvc ......here iam using a grid view in mvc2 application ........while selecting the value in gridview the page is automatically refershing.........putted in update panel,panel it is also not working...............so plz help me
here is my code
Delete Role
Select a row to delete…..
BackColor="#D8DEE5" BorderColor="#010173"
EnableSortingAndPagingCallbacks="false" CellSpacing="2"
HorizontalAlign="Center" PageSize="5" Height="182px" Width="756px"
onselectedindexchanged="GridView1_SelectedIndexChanged1"
AutoGenerateSelectButton="True">
Delete
in model:
C#
public bool deleterole(int roleno)
{
DataClasses1DataContext dc = new DataClasses1DataContext();
roledet rd = new roledet();
var delrole = from role in dc.roledets where role.roleno == roleno select role;
foreach (var v in delrole)
{
rd.roleno = v.roleno;
dc.roledets.DeleteOnSubmit(rd);
dc.SubmitChanges();
}
return true;
}in controller:
[HttpPost]
C#
public ActionResult Delete(RoleClass r)
{
if (ModelState.IsValid)
{
int roleno = Convert.ToInt32(ViewData["roleno"]);
bool b = r.deleterole(roleno);
if (b == true)
{
Response.Write("");
}
else
{
Response.Write("");
}
}
return View(r);
}
Answers
Know the answer? Post it. Somebody with the same question will find it here.