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.
Author |
Topic |
mapidea
Posting Yak Master
124 Posts |
Posted - 2010-01-07 : 12:55:11
|
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:46
|
Oh so it was duplicate. please dont crossposthttp://www.sqlteam.com/forums/topic.asp?TOPIC_ID=138038 |
|
|
mapidea
Posting Yak Master
124 Posts |
Posted - 2010-01-07 : 13:12:18
|
Ok Visakh. |
|
|
mapidea
Posting Yak Master
124 Posts |
Posted - 2010-01-09 : 14:10:53
|
I got it right. protected void GridView2_RowCreated(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { try { if (e.Row.RowIndex > 0) { //Separating the orders. Label lbl_order_number = (Label)GridView2.Rows[e.Row.RowIndex - 1].Cells[2].FindControl("order_number"); string strGroup = String.Empty; if (lbl_order_number.Text.ToString() != strGroup) { if (string.IsNullOrEmpty(strGroup)) { TableCell tc = new TableCell(); tc.Text = " "; tc.Height = Unit.Pixel(10); tc.BackColor = System.Drawing.Color.FromName("#F0E68C"); //you can change this to adjust to the space you want tc.Attributes["ColSpan"] = GridView2.Columns.Count.ToString(); GridViewRow gr = new GridViewRow(1, -1, DataControlRowType.Separator, DataControlRowState.Normal); gr.Cells.Add(tc); GridView2.Controls[0].Controls.AddAt(GridView2.Controls[0].Controls.Count -1, gr); } strGroup = lbl_order_number.Text.ToString(); } else { TableCell tc = new TableCell(); tc.Text = " "; tc.Height = Unit.Pixel(10); tc.BackColor = System.Drawing.Color.FromName("#B0C4DE"); //you can change this to adjust to the space you want tc.Attributes["ColSpan"] = GridView2.Columns.Count.ToString(); GridViewRow gr = new GridViewRow(1, -1, DataControlRowType.Separator, DataControlRowState.Normal); gr.Cells.Add(tc); GridView2.Controls[0].Controls.AddAt(GridView2.Controls[0].Controls.Count - 1, gr); strGroup = lbl_order_number.Text.ToString(); } } } catch (Exception ex) { sub_exception_message_display(ex.Message); } } } |
|
|
|
|
|
|
|