Re: datagrid,spliting value from database

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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!
>
>
>
>
.



Relevant Pages

  • access database not updating
    ... When I try to update my access database, ... As String) As Integer ... DataGridCommandEventArgs) ... Prev by Date: ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: ASP.Net 2.0: Problem User.isinrole() instead o
    ... > string s = Context.User.GetType.FullName; ... > Dominick Baier - DevelopMentor ... >>> Hello Stefan, ... Prev by Date: ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • Re: Split, Substring and other functions in expression editor?
    ... Jon Flanders ... "Sam Loveridge" wrote in message ... >> Jon Flanders [DevelopMentor] ... I'm trying to take a string variable in the BizTalk Expression ...
    (microsoft.public.biztalk.general)
  • Re: datagrid - wert auslesen
    ... > Bearbeiten - Link hinzugefügt, wenn man den klickt kann man die Werte ... DataGridCommandEventArgs) ... TextBox).Text Dim lname As String = ...
    (microsoft.public.de.german.entwickler.dotnet.asp)
  • String to Int
    ... Richard Blewett - DevelopMentor ... Kind of a newbie question, but I need to be able to convert a string to ...
    (microsoft.public.dotnet.languages.csharp)