Problem in data grid in ASP.Net 2003

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ShoaibAta
    New Member
    • Aug 2006
    • 1

    Problem in data grid in ASP.Net 2003

    Hi Everyone,

    I have two fields in data grid i.e. ID and DESCRIPTION. Description field is a link button and ID field is hidden. I want that when I click on description field then another page should be open on the basis of ID field value. How can I get the value of ID field in query string. Keep in mind that ID is a hidden field. Can anyone solve my problem
  • nateraaaa
    Recognized Expert Contributor
    • May 2007
    • 664

    #2
    Originally posted by ShoaibAta
    Hi Everyone,
    I have two fields in data grid i.e. ID and DESCRIPTION. Description field is a link button and ID field is hidden. I want that when I click on description field then another page should be open on the basis of ID field value. How can I get the value of ID field in query string. Keep in mind that ID is a hidden field. Can anyone solve my problem
    I think the easiest way to accomplish this would be to use the CommandName and CommandArgument properties of the LinkButton.

    [HTML]<asp:LinkButt on ID="lnkButton" Runat="server" CommandArgument ='<%# DataBinder.Eval (Container,"Dat aItem.ID")%>' CommandName="De tails"></asp:LinkButton> [/HTML]

    Then in the ItemCommand event of your datagrid you can check the value of e.CommandName and then open the page you want with a querystring value = to e.CommandArgume nt

    Code:
    public void DataGrid1_ItemCommand(object source, DataGridCommandEventArgs e)
    		{
    			if(e.Item.ItemType != ListItemType.Header && e.Item.ItemType != ListItemType.Pager)
    			{
    				if(e.CommandName == "Details")
    				{
    					Response.Redirect("NewPage.aspx?value=" + e.CommandArgument);
    				}
    			}			
    		}

    Comment

    Working...