Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
395
Please Help
posted

I have normal grid in ASP.NET and I am converting it into webdata grid.

Now my grid has functionalities of opening file, copy file, edit description of file, emailing file and deleting file.

It is based on documents.

Now suppose if I take example of deleting file the original code is:

  protected void lbEmailDocument_Click(object sender, CommandEventArgs e)

    {

        int index = Int32.Parse(e.CommandArgument.ToString());

        Session["strDocumentToAttach"] = ((Label)gvDocuments.Rows[index].Cells[0].FindControl("lblPath")).Text;

        Session["strSubject"] = "Case Document E-mail (Case # " + lblCaseNumber.Text.Trim() + ")";

        Session["strNote"] = "Please find the attached document " + ((Label)gvDocuments.Rows[index].Cells[0].FindControl("lblFileName")).Text;

        ScriptManager.RegisterStartupScript(Page, this.GetType(), "myPopUp", "<script language='Javascript'>mywin=window.open('Case_Email.aspx?CaseID=" + lblCaseID.Text + "', '', 'location=0,status=0,resizable=1,scrollbars=1,height=920px, width=1250px');mywin.moveTo(0,0);</script>", false);

 

        // Response.Redirect("Case_Email.aspx?CaseID=" + lblCaseID.Text);

    }

 

------------------------------------------------------------------------------------------------------------------------------

Now when I change this : Instead of Rows[index].Cells[0] I am not able to access the cell value.

 

Please guide me through, How to change it.

 

 

 

 

Parents
No Data
Reply
  • 49378
    posted

    Hi beburulesforever,

    Thank you for posting in the community.

    I have created a sample for you demonstrating how to access the different cells in a row in WebDataGrid (both using the column key and by column index). In WebDataGrid the Items collection is used to access the cells in a row as such :


    protected void Button1_Click(object sender, EventArgs e)
    {
       
    //here the item (cell) is accessed by column key
       
    Label1.Text = WebDataGrid1.Rows[0].Items.FindItemByKey("Name").Value.ToString();
       
    //item's templated label is accessed (here the item is accessed by index)
       
    Label1.Text = Label1.Text + " " + ((Label)WebDataGrid1.Rows[0].Items[0].FindControl("TemplatedLabel")).Text;

    Attached is also a simple sample illustrating this scenario. Please do not hesitate to contact me if you need further assistance.

    Best Regards,

    Petar Ivanov
    Developer Support Engineer
    Infragistics, Inc.
    http://ko.infragistics.com/support

    WebDataGridGetTemplatedItem.zip
Children