Click here to Skip to main content
15,906,624 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: I Need Quick help Plz anybody... Pin
Sathyaa1528-Jun-07 0:55
Sathyaa1528-Jun-07 0:55 
QuestionSending Mail Problem. Pin
deepaks327-Jun-07 8:38
deepaks327-Jun-07 8:38 
AnswerRe: Sending Mail Problem. Pin
Christian Graus27-Jun-07 10:55
protectorChristian Graus27-Jun-07 10:55 
GeneralRe: Sending Mail Problem. Pin
deepaks327-Jun-07 18:02
deepaks327-Jun-07 18:02 
QuestionHelp needed in performing validation Pin
gayathri_it200527-Jun-07 7:39
gayathri_it200527-Jun-07 7:39 
AnswerRe: Help needed in performing validation Pin
Not Active27-Jun-07 8:21
mentorNot Active27-Jun-07 8:21 
QuestionHttpWebRequest Pin
dekart_roo27-Jun-07 5:51
dekart_roo27-Jun-07 5:51 
QuestionDelete row from GridView which is bound to DataTable [modified] Pin
kjosh27-Jun-07 5:15
kjosh27-Jun-07 5:15 
Hi,
I have the Gridview which is bound to DataTable. In the GridView I have one button Delete for each row , when clicking on button the row need to be deleted from gridview.
private void BindGrid()
{
GridView1.DataSource = GetDataSource();
GridView1.DataBind();
}

protected System.Data.DataTable GetDataSource()
{
// const string key = "MyDataSource";
System.Data.DataTable aTable = new System.Data.DataTable();
aTable = (System.Data.DataTable)Session["dta"] ;

if (aTable == null)
{
aTable = CreateDataTableA(); -- In this CreateTable I am creating one DataTable and returning it.
Session["dta"] = aTable;

}
return aTable;


}

protected void GridView1_RowDeleting(object sender,GridViewDeleteEventArgs e)
{
int id = Convert.ToInt32( (GridView1.Rows[e.RowIndex].Cells[0].Text.ToString())); -- This statement containg null value always. This is giving exception because of this Null value.
FindRowByID(id).Delete();
BindGrid();
}

private DataRow FindRowByID(int id)
{
DataRow[] rows = GetDataSource().Select("District_ID = " + id.ToString());
return rows[0];
}
How to get the row’s cell value when delete button is clicked.

My Gridview syntax is like this:
<asp:gridview id="GridView1" runat="server" autogeneratecolumns="False" onrowdeleting="GridView1_RowDeleting">
<columns>
<asp:templatefield headertext="District_ID">
<edititemtemplate>
<asp:textbox id="TextBox1" runat="server">

<itemtemplate>
<asp:label id="Label1" runat="server" text="<%# DataBinder.Eval(Container.DataItem, "District_ID") %>" width="115px">


<asp:templatefield headertext="District_Name">
<edititemtemplate>
<asp:textbox id="TextBox2" runat="server">

<itemtemplate>
<asp:label id="Label2" runat="server" text="<%# DataBinder.Eval(Container.DataItem, "District_Name") %>">


<asp:commandfield buttontype="Button" deletetext="-" showdeletebutton="True" showheader="True">



Thanks in advance.





-- modified at 11:32 Wednesday 27th June, 2007
AnswerRe: Delete row from GridView which is bound to DataTable Pin
Urs Enzler27-Jun-07 8:34
Urs Enzler27-Jun-07 8:34 
QuestionValues in array Pin
afreshpulse27-Jun-07 4:45
afreshpulse27-Jun-07 4:45 
AnswerRe: Values in array Pin
RichardGrimmer27-Jun-07 5:45
RichardGrimmer27-Jun-07 5:45 
GeneralRe: Values in array Pin
afreshpulse27-Jun-07 6:24
afreshpulse27-Jun-07 6:24 
GeneralRe: Values in array Pin
Urs Enzler27-Jun-07 8:40
Urs Enzler27-Jun-07 8:40 
GeneralRe: Values in array Pin
RichardGrimmer27-Jun-07 9:38
RichardGrimmer27-Jun-07 9:38 
QuestionNo. of hites facility in my website Pin
pathak7827-Jun-07 4:42
pathak7827-Jun-07 4:42 
AnswerRe: No. of hites facility in my website Pin
Christian Graus27-Jun-07 11:00
protectorChristian Graus27-Jun-07 11:00 
AnswerRe: No. of hites facility in my website Pin
Vasudevan Deepak Kumar27-Jun-07 21:40
Vasudevan Deepak Kumar27-Jun-07 21:40 
QuestionProperty value after PostBack of UserControl Pin
ZeedijkMike27-Jun-07 4:41
ZeedijkMike27-Jun-07 4:41 
AnswerRe: Property value after PostBack of UserControl Pin
ZeedijkMike27-Jun-07 4:43
ZeedijkMike27-Jun-07 4:43 
AnswerRe: Property value after PostBack of UserControl Pin
SHatchard27-Jun-07 5:28
SHatchard27-Jun-07 5:28 
GeneralRe: Property value after PostBack of UserControl Pin
ZeedijkMike27-Jun-07 5:56
ZeedijkMike27-Jun-07 5:56 
AnswerRe: Property value after PostBack of UserControl Pin
Urs Enzler27-Jun-07 8:44
Urs Enzler27-Jun-07 8:44 
QuestionRetrieving Property value after PostBack of UserControl Pin
ZeedijkMike27-Jun-07 4:39
ZeedijkMike27-Jun-07 4:39 
AnswerRe: Retrieving Property value after PostBack of UserControl Pin
Venkatesh Mookkan27-Jun-07 17:38
Venkatesh Mookkan27-Jun-07 17:38 
QuestionSQL Query works intermittently... Pin
TenmanS1427-Jun-07 4:39
TenmanS1427-Jun-07 4:39 

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.