Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 GridView

Author  Topic 

mapidea
Posting Yak Master

124 Posts

Posted - 2010-01-07 : 13:03:20
I have a gridview with has lots of fields. There are buttons which have CommandArgument set and which are being accessed in the RowCommand of the GridView.

The command argument are being populated with

------------
<asp:Button ID="DeAllocate" runat="server" Text="DeAllocate" CommandArgument='<%# Eval("order_id") + "," + Eval("product_id") + "," + Eval("order_item_id") %>' CommandName="DeAllocate" CssClass="SubmitButtonStyle" />

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

I am also adding a separator row with the following code.


------------
protected void GridView2_RowDataBound(object sender, GridViewRowEventArgs e)

{

TableCell tc = new TableCell();
tc.Text = " ";
tc.Height = Unit.Pixel(10);
tc.BackColor = Color.FromName("#F0E68C");
//you can change this to adjust to the space you want
GridView gv1 = (GridView)sender;
tc.Attributes["ColSpan"] = gv1.Columns.Count.ToString();

GridViewRow gr = new GridViewRow(1, -1, DataControlRowType.Separator, DataControlRowState.Normal);

gr.Cells.Add(tc);

Table gvTable = (Table)e.Row.Parent;

gvTable.Rows.AddAt(gv1.Controls[0].Controls.Count - 1, gr);}



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



After adding this separator row. I am not able to get the CommandArgument. All the values which I am declaring in the Aspx with "Eval" are Null when I access them in RowCommand. If I remove the separator row it is working fine.

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

protected void GridView2_RowCommand(object sender, GridViewCommandEventArgs e)
{

if (e.CommandName == "DeAllocate")
{
try
{
string[] CommandArgument = e.CommandArgument.ToString().Split(',');

long var_order_id = Convert.ToInt64(CommandArgument[0]);
long var_item_id = Convert.ToInt64(CommandArgument[1]);
long var_order_item_id = Convert.ToInt64(CommandArgument[2]);

}
-------------------

Thanks a lot

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-01-07 : 13:06:10
i think this should be posted in .net forum here
Go to Top of Page
   

- Advertisement -