Re: datagrid,spliting value from database
- From: "LU" <LU@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 28 Apr 2005 14:58:02 -0700
This works, but it how do I remove one of them when it only has 1 number and
not 2?
so If i have 3/4 it works, but what about if I have 1 or 10
It seems I will have an extra button.
"Brock Allen" wrote:
> <ItemTemplate>
> <asp:Button runat=server CommandName="MyButton" CommandArgument='<%# GetLeftHalf(Container.DataItem)
> %>' Text="LeftHalf" />
> <asp:Button runat=server CommandName="MyButton" CommandArgument='<%# GetRightHalf(Container.DataItem)
> %>' Text="RightHalf" />
> </ItemTemplate>
>
> Where GetLeftHalf:
>
> string GetLeftHalf(object data)
> {
> string s= (string)data;
> return s.Split('/')[0]; // do better error checking that i am here :)
> }
>
> Then to handle the click handle the DataGrid's ItemCommand event:
>
> void Grid_ItemCommand(object s, DataGridCommandEventArgs e)
> {
> if (e.CommandName == "MyButton")
> {
> string theNumber = e.CommandArgument;
> /// and so on...
> }
> }
>
> This is very rough as it's off the top of my head, but I think it should
> get you started in the right direction.
>
> -Brock
> DevelopMentor
> http://staff.develop.com/ballen
>
>
>
> > Yes, but how do I make that work inside the datagrid ?
> >
> > "Brock Allen" wrote:
> >
> >> string s = "3/4";
> >> string[] parts = s.Split('/');
> >> // use parts[0] and parts[1]
> >> -Brock
> >> DevelopMentor
> >> http://staff.develop.com/ballen
> >>> VAR1 = 3/4
> >>> VAR2 = 2
> >>> I user can submit the values "3/4" or "2" (VAR1, VAR2 represent any
> >>> numbers)
> >>> when user submits "3/4" we assume 1sthalf/2ndhalf
> >>> These values are saved into database as a row
> >>> row1: 3/4
> >>> row2: 2
> >>> I have a datagrid that displays values just fine, but user wants to
> >>> beable
> >>> to click on the 3 or 4 when we have a "/" in the value.
> >>> How do I split the value when it finds a "/" ,
> >>> then create a button column(for an event) for each value. This
> >>> would
> >>> allow
> >>> the user to click the 3 "or" 4 in 3/4 and then i could run an event
> >>> based on
> >>> what they clicked.
> >>> so,
> >>> I was thinking
> >>> <a href="p.aspx?id=1sthalf&value=3">3</a> /
> >>> <a href="p.aspx?id=2ndhalff&value=4">4</a>
> >>> I don't know how to do something like this in the data grid and/or
> >>> datalist.
> >>> If it doesn't find a "/" it should assume 1sthalf.
> >>> Any ideas, hints, HELP would be GREAT!
>
>
>
>
.
- Follow-Ups:
- Re: datagrid,spliting value from database
- From: Brock Allen
- Re: datagrid,spliting value from database
- References:
- datagrid,spliting value from database
- From: LU
- Re: datagrid,spliting value from database
- From: Brock Allen
- Re: datagrid,spliting value from database
- From: LU
- Re: datagrid,spliting value from database
- From: Brock Allen
- datagrid,spliting value from database
- Prev by Date: Re: C# ASP.NET Thumbnail Generator issue
- Next by Date: display mutiple rows data fields for single record
- Previous by thread: Re: datagrid,spliting value from database
- Next by thread: Re: datagrid,spliting value from database
- Index(es):
Relevant Pages
|